So I have four columns of data, but only two (Column C and D) that I wish to sort. One column is a list of Work Center Names (Column C) and the other is Operation Numbers (Column D). What I want to know is how to sort the Work Center Names in Alphabetical Order and then within each Work Center Name, Sort the Operation Numbers in Ascending Order.
So the Data would end up looking like: (assuming x is a random column value)
x x LDHF 10
x x LDHF 20
x x LDHF 30
x x SHFT 10
x x SHFT 20
x x SHFT 30
Currently, this is my code. It sorts one column but then when it sorts the second, it overwrites the first sort and scrambles the other column.
ActiveWorkbook.Worksheets("Percent").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Percent").Sort.SortFields.Add Key:=Range( _
"D1:D" & DailyLastRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Percent").Sort
.SetRange Range("A1:D" & DailyLastRow)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWorkbook.Worksheets("Percent").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Percent").Sort.SortFields.Add Key:=Range( _
"C1:C" & DailyLastRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Percent").Sort
.SetRange Range("A1:D" & DailyLastRow)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With