View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default sort function - from ascending to descending

It should work as demonstrated he

Sub BubbleDown()
Dim First As Integer, Last As Integer
Dim i As Integer, j As Integer
Dim Temp As Integer
List = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
First = LBound(List)
Last = UBound(List)
For i = First To Last - 1
For j = i + 1 To Last
If List(i) < List(j) Then
Temp = List(j)
List(j) = List(i)
List(i) = Temp
End If
Next j
Next i
For i = First To Last
Debug.Print i, List(i)
Next
End Sub

--
Regards,
Tom Ogilvy


"jimmyp" wrote:


i tried that - it almost works :) but misses of the largest element, ie
the one that should be at the start...the rest are all in descending
order though


--
jimmyp
------------------------------------------------------------------------
jimmyp's Profile: http://www.excelforum.com/member.php...o&userid=32217
View this thread: http://www.excelforum.com/showthread...hreadid=522186