Multi table sort.
I have 6 tables plus that need sorting as above in the recorded macro.
Each table is the same size
a2:i21
a25:i44
a48:i67 etc.
23 row between tables. How can vba sort all the tables please?
VBA Code:
Sub Button1_Click()
Range("A2:I21").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("I3:I21") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("H3:H21") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("F3:F21") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A2:I21")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("M10").Select
End Sub
I have 6 tables plus that need sorting as above in the recorded macro.
Each table is the same size
a2:i21
a25:i44
a48:i67 etc.
23 row between tables. How can vba sort all the tables please?