Userform listbox sort columns by clicking on header

STYoda 1 Reputation point
2021-08-24T22:24:20.907+00:00

Hi,

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.

126086-image.png

Thanks
ST

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
    2022-01-18T22:58:08.26+00:00

    Yes.
    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.