Userform listbox sort columns by clicking on header

STYoda 1 Reputation point


In Excel vba, I have a listbox in a Userform and would like to sort the column when a column header is clicked.
Is this possible?
So, if I click on column 6 header then it will arrange all the columns by column 6 alphabetically, and then if I clicked column 6 again then it would reverse the order.



Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,596 questions
Excel Management
Excel Management
Excel: A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.Management: The act or process of organizing, handling, directing or controlling something.
1,661 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Martin 1 Reputation point

    I presume that the listbox is being 'rowsourced' by a table/list in a sheet.
    If it was me - I would make the listbox commandheads property false then place command buttons above the headings, that when clicked go to the source sheet and sort the data as required, then re-source the listbox property.