aurelius89
Board Regular
- Joined
- Mar 15, 2017
- Messages
- 69
I have recorded the following macro while doing my custom sort:
I have cleaned it up a little by removing selects and defining my worksheet as a variable. Any other way this can be made more efficient or cleaned up?
Code:
Sub sortMembers()
Dim ws As Worksheet: Set ws = Worksheets("RefindData")
ws.sort.SortFields.Clear
ws.sort.SortFields.Add Key:=Range( _
"A2:A9998"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ws.sort.SortFields.Add Key:=Range( _
"C2:C9998"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
ws.sort.SortFields.Add Key:=Range( _
"F2:F9998"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ws.sort
.SetRange Range("A1:P9998")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
I have cleaned it up a little by removing selects and defining my worksheet as a variable. Any other way this can be made more efficient or cleaned up?