I'm trying to automate the sort function in excel (by levels).
So I would like to first sort Column B by A-Z
Then the next level is sort Column N from oldest to newest date
The problem with the macro below, is it sorts Column B fine (A-Z), but then it doesn't apply the "level" criteria, and it just jumbles up the dates in Column N (from oldest to newest), and it doesn't tally with the data in Column B. How would I fix this? Most appreciated, thanks.
So I would like to first sort Column B by A-Z
Then the next level is sort Column N from oldest to newest date
The problem with the macro below, is it sorts Column B fine (A-Z), but then it doesn't apply the "level" criteria, and it just jumbles up the dates in Column N (from oldest to newest), and it doesn't tally with the data in Column B. How would I fix this? Most appreciated, thanks.
VBA Code:
Sub SortColumnsBAndN()
'Sort Column B by A-Z
Columns("B:B").Sort key1:=Range("B2"), Order1:=xlAscending, Header:=xlYes
'Sort Column N by oldest to newest date
Columns("N:N").Sort key1:=Range("N2"), Order1:=xlAscending, Header:=xlYes, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers, _
Header:=xlYes
End Sub