Just create an array to store the six numbers. then pass the array to the following bubblesort (a slow sorting method)
Code:Public Sub BubbleSort(ByRef arr As Variant, Optional numEls As Variant, Optional descending As Boolean) Dim value As Variant Dim Index As Long Dim firstItem As Long Dim indexLimit As Long, lastSwap As Long ' account for optional arguments If IsMissing(numEls) Then numEls = UBound(arr) firstItem = LBound(arr) lastSwap = numEls Do indexLimit = lastSwap - 1 lastSwap = 0 For Index = firstItem To indexLimit value = arr(Index) If (value > arr(Index + 1)) Xor descending Then ' if the items are not in order, swap them arr(Index) = arr(Index + 1) arr(Index + 1) = value lastSwap = Index End If Next Loop While lastSwap End Sub




Reply With Quote