I have a vague recollection that Excel VBA does not do sorting. Is that why when I run the following code:
I get the message: "The sort reference is not valid. Make sure that it's in the data you want to sort, and the first SortBy box isn't the same or blank". That message occurs at the ".Apply". I'm not aware that there is supposed to be a SortBy box. I can't find any information in Help on how to use it.
Thanks for any help,
Paul Hudgens
Denver
Code:
For i = 0 To iTotalZones
iOffset = i * 3
With Workbooks(ThisWkBk).Worksheets("Operators")
Set SortRange = .Range(.[A2].Offset(0, iOffset + 1), .[A2].Offset(0, iOffset + 2).End(xlDown))
End With
SortRange.Activate
SortRange.Select
ActiveWorkbook.Worksheets("Operators").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Operators").Sort.SortFields.Add Key:= _
SortRange, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Operators").Sort
.SetRange SortRange
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Next i
I get the message: "The sort reference is not valid. Make sure that it's in the data you want to sort, and the first SortBy box isn't the same or blank". That message occurs at the ".Apply". I'm not aware that there is supposed to be a SortBy box. I can't find any information in Help on how to use it.
Thanks for any help,
Paul Hudgens
Denver