
Originally Posted by
rorya
It means your macro does something wrong when applying a sort. Usually it's that you forgot to clear the existing sortfields before adding new ones, but it would be easier to be sure if we could actually see the code...

Ah ok, I'm only new to VBA, so I'm just learning as I go along. The code is written to sort the teams on the basis of points, and if the points are equal then goal difference, and if both are equal then it sorts by goals for. This is the part of the code with the sort:
For Each cell In team
cell.Activate
If ActiveCell.Offset(0, 8) <> ActiveCell.Offset(1, 8) Then
With ActiveSheet.Sort
.SortFields.Add Key:=Range("J1"), Order:=xlDescending
.SetRange Range("B1:CA21")
.Header = xlYes
.Apply
End With
ElseIf ActiveCell.Offset(0, 8) = ActiveCell.Offset(1, 8) Then
With ActiveSheet.Sort
.SortFields.Add Key:=Range("I1"), Order:=xlDescending
.SetRange Range("B1:CA21")
.Header = xlYes
.Apply
End With
ElseIf (ActiveCell.Offset(0, 8) = ActiveCell.Offset(1, 8)) And ActiveCell.Offset(0, 7) = ActiveCell.Offset(1, 7) Then
With ActiveSheet.Sort
.SortFields.Add Key:=Range("G1"), Order:=xlDescending
.SetRange Range("B1:CA21")
.Header = xlYes
.Apply
End With
End If
Next cell
Bookmarks