title: VBA - How to sort values in listbox in ascending order?
body: <p>I am looking for a way to sort items in my userform listbox. So far I have the code below:</p>
  
  <pre><code>Dim i As Long
  Dim j As Long
  Dim Temp As Variant
  With ListBoxName
      For i = 0 To .ListCount - 2
          For j = i + 1 To .ListCount - 1
              If .List(i) &gt; .List(j) Then
                  Temp = .List(j)
                  .List(j) = .List(i)
                  .List(i) = Temp
              End If
          Next j
      Next i
  End With
  </code></pre>
  
  <p>This code works but sadly, it does not sort the numbers properly. I want to sort the numbers the following way:
  1,2,3,4,5,6,7,8,9,10,11,12,13,14</p>
  
  <p>but my code sorts these number like this:
  1,10,11,12,13,14,2,3,4,5,6,7,8,9</p>
  
  <p>How can I sort items in listbox numerically in ascending order? I populate the listbox using <code>ListBoxName.AddItem</code> command. What am I doing wrong?</p>