View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
pikus pikus is offline
external usenet poster
 
Posts: 1
Default Calling Bubble Sort Function

Bubble sort is too slow. This was written to sort an Excel spreadsheet
but you can definitely adapt it to work with your array. Basically it
searches the un-sorted items to find the lowest value and places that
at the top.

Sub SortByCount(ctrStart As Long, ctrEnd As Long)

Dim foo As Integer
Dim bar As Integer
Dim fizz As Integer
Dim nums As Worksheet

Set nums = Worksheets("FinalNumbers")
bar = ctrStart

Do
foo = 0
fizz = -100
For x = bar To ctrEnd
If nums.Cells(x, 7).Value = fizz Then
foo = x
fizz = nums.Cells(x, 7).Value
End If
Next x

If foo < bar And foo < 0 Then
nums.Rows(foo).Cut
nums.Rows(bar).Insert
End If

bar = bar + 1
Loop Until bar = ctrEnd

End Sub


---
Message posted from http://www.ExcelForum.com/