I created the following code to sort one sheet by 2 columns, but I would like to change the code to include other sheets (but not all the sheets w/in the workbook). How can I do that? All the data will be in the same columns and cells on each sheet. Also, can I still use the sheet names or should the code be changed to the sheet numbers?
Sub SortColumn()
Range("B11:M123").Select
ActiveWindow.SmallScroll Down:=-102
ActiveWorkbook.Worksheets("Break").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Break").Sort.SortFields.Add Key:=Range("K11:K123") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Break").Sort.SortFields.Add Key:=Range("C11:C123") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Break").Sort
.SetRange Range("B11:M123")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub SortColumn()
Range("B11:M123").Select
ActiveWindow.SmallScroll Down:=-102
ActiveWorkbook.Worksheets("Break").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Break").Sort.SortFields.Add Key:=Range("K11:K123") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Break").Sort.SortFields.Add Key:=Range("C11:C123") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Break").Sort
.SetRange Range("B11:M123")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Last edited: