I'd like to know if you have a neater way of sorting collections that contain only numbers.
[VBA]Option Explicit
Option Base 1
Sub TestSorting()
Dim mycol As Collection
Dim n As Long
Set mycol = New Collection
mycol.Add 25, "25"
mycol.Add 83, "83"
mycol.Add 12, "12"
mycol.Add 14, "14"
mycol.Add 10, "10"
Debug.Print vbCrLf
For n = 1 To mycol.Count
Debug.Print mycol(n),
Next n
Set mycol = SortCollection(mycol)
Debug.Print
For n = 1 To mycol.Count
Debug.Print mycol(n),
Next n
Set mycol = Nothing
End Sub
Function SortCollection(col As Collection) As Collection
Dim n As Integer
Dim dblSmall As Double
Dim dblArray() As Double
Set SortCollection = New Collection
ReDim dblArray(col.Count)
For n = 1 To col.Count
dblArray(n) = col(n)
Next n
For n = 1 To col.Count
dblSmall = WorksheetFunction.Small(dblArray, n)
SortCollection.Add dblSmall, CStr(dblSmall)
Next n
Set col = Nothing
End Function
[/VBA]
In my approach, I used an array to get the collection's values and used worksheet function small to get the desired numbers.