We help IT Professionals succeed at work.

Auto sort macro by surname then first name

vegas86
vegas86 asked
on
Hello,

I have the following macro currently in my sheet,

'
' AutoSortApplication
    Range("A11:XFC5000").Sort Key1:=Range("F11"), Order1:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:= _
        False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
End Sub

how do I edit this so it also then sorts by first name ascending the range would be E11. At the moment it is only sorting surnames but I woiuld like it to then sort the first names accordingly.
Comment
Watch Question

Does this work?
Range("A11:XFC5000").Sort Key1:=Range("F11"), Order1:=xlAscending, key2:=Range("E11"), order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:= _
        False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

Open in new window

Author

Commented:
Works perfectly, thank you!!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.