Private Sub Sort_Click()
Dim MaxLap As Integer
Dim Rdone As Integer
Dim Onlap As Integer
Dim tl As Integer
Dim br As Integer
'A Grade
Worksheets("A Grade").Range("G5:IV104").Sort Key1:=Worksheets("A
Grade").Range("I5"), Order1:=xlDescending, _
DataOption1:=xlSortNormal
MaxLap = Worksheets("A Grade").Range("I5")
Rdone = 0
If MaxLap > 0 Then
For l = MaxLap To 1
Onlap = WorksheetFunction.CountIf(Worksheets("A Grade").Range("I5:I104"), l)
If Onlap > 0 Then
tl = 5 + Rdone
br = 4 + Onlap + Rdone
Worksheets("A Grade").Range("G" & tl & ":IV" & br).Sort Key1:=Worksheets("A
Grade").Range(("i" + Onlap) & tl), Order1:=xlascending,
DataOption1:=xlSortNormal
Rdone = Rdone + Onlap
End If
Next l
End If
A very brief explanation of what is happening. There is a list of riders
with lap times adjacent. The riders can all have varying amounts of laps.
Column i is the number of laps completed. First i sort by number of laps
completed in descending order. Then I am trying to sort the sub groups of
riders who have finished the same amount of laps by the time they finished
their last lap (furthest used column to the right of column I) in ascending
order. Hope this helps a bit.