Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
How to sort the items listed in a combobox in vba?
Thank you very much in advance.
Solved! Go to Solution.
Hello!
How to sort the items listed in a combobox in vba?
Thank you very much in advance.
Solved! Go to Solution.
Unfortunately, combobox in VBA does not come with a sort feature you can use. You need to sort the data list before adding them to the combobox. if the dropdown list has to sort differently at run time, you need to clear the combobox, resort the data list and re-add them back to the combobox.
Since the built-in data structure in VBA (array, collection) also do not have built-in sorting method, you need to write your own sorting code. Fortunately there are a lot code samples on the net for various sorting algorithms that you can directly use, or with minor modification.
Thank you Norman for the attention!
But today I managed to solve this.
The code is not mine, but I adapted it to my need
and gave it right. If any companions need you can adapt to your need as well. This is the link:
https://forums.autodesk.com/t5/visual-basic-customization/sorting-list-boxes-in-vba/m-p/301704#M4798
Regards!