I am trying to create a macro that executes a two-level sort using a custom list for a dynamic table.
- Level 1: Sort by (Range "C2") // Sort on (Cell Values) // Order (Oldest to Newest)
- Level 2: Sort by (Range "D2") // Sort on (Cell Values) // Order (Custom List)
The table is updated on a daily basis and, therefore, requires the macro to capture a varying number of rows.
The Custom List that I would like to order the Location column by is: "Greater London, Liverpool, Birmingham, Manchester, Sheffield, Leeds, Bristol" - (in reality my custom list is rather long and consists of various strings).
The below is what I have written so far and would appreciate any input. Thanks!
Sub CustomSort()
Range("B2").CurrentRegion.Sort _
key1:= Range("C2"), Order1:=xlAscending, Orientation:=xlTopToBottom, Header:=xlYes, _
key2:= Range("D2"), Order1:=xlAscending, Orientation:=xlTopToBottom, Header:=xlYes, CustomOrder:= _
"Greater London,Liverpool,Birmingham,Manchester,Sheffield,Leeds,Bristol"
End Sub

SORTBYfunction as well (see e.g. exceljet.net/formula/sort-by-custom-list)Datein "C:C" there are many cases of different locations. Such a picture could help only if it is appropriate and followed by another one showing how you like the data to be sorted. You can see how to deal with the sorting itself in the link posted above...