excel – VBA – How to sort values in listbox in ascending order?

excel – VBA – How to sort values in listbox in ascending order?

Try, please replacing of

If .List(i) > .List(j) Then

with

If CLng(.List(i)) > CLng(.List(j)) Then 

and change:

Temp = CLng(.List(j)) 

In this way, the comparison it is done between numbers, not between strings.

But if you have also strings in the list box, the code will return an error…

excel – VBA – How to sort values in listbox in ascending order?

Leave a Reply

Your email address will not be published.