I've been slowly working my way thru an old excel spreadsheet which is loaded with macro's in an attempt to simplify them and make them more efficient. My attempt to simplify a sort has been unsuccessful and, despite many searches on the internet, I am unable to determine where I'm going wrong.
Here is my original code which does work.
Here is the new code I've been trying to debug and implement.
Any thoughts on what I'm doing wrong would be greatly appreciated.
Thanks,
Don
Here is my original code which does work.
VBA Code:
Range("F43:I72").Select
ActiveWorkbook.Worksheets("AllWeeks").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("AllWeeks").Sort.SortFields.Add Key:=Range( _
"h43:h72"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("AllWeeks").Sort.SortFields.Add Key:=Range( _
"G43:G72"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("AllWeeks").Sort.SortFields.Add Key:=Range( _
"I43:I72"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("AllWeeks").Sort
.SetRange Range("F43:I72")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Here is the new code I've been trying to debug and implement.
VBA Code:
Worksheets("AllWeeks").Sort.SortFields.Clear
Range("F43:I72").Sort Key1:=Range("H43"), Key2:=Range("G43"), Key3:=Range("I43"), Order1:=xlAscending, Order2:=xlAscending, Order3:=xlAscending, Header:=x1No
Any thoughts on what I'm doing wrong would be greatly appreciated.
Thanks,
Don
Last edited by a moderator: