Hi excel users.
I have vba code that sorts a table via 3 criteria (Year, Gender and last name). The problem is I am getting a 'compile error: defined name not found' message.
It seems not to like the CustomOrder1 code (causing the error).
The code works if I use the macro recorder to create the code, but when I tried to clean it up, I can't seem to quite get it to work.
What am I missing?
Thanks.
I have vba code that sorts a table via 3 criteria (Year, Gender and last name). The problem is I am getting a 'compile error: defined name not found' message.
It seems not to like the CustomOrder1 code (causing the error).
The code works if I use the macro recorder to create the code, but when I tried to clean it up, I can't seem to quite get it to work.
What am I missing?
Thanks.
Code:
Sub sort()
With Range("table2")
.Sort Key1:=Range("Table2[Year]"), Order1:=xlAscending, CustomOrder1:="K,1,2", _
Key2:=Range("Table2[Gender]"), Order2:=xlAscending, _
Key3:=Range("Table2[Last name]"), Order3:=xlAscending, _
MatchCase:=False, Orientation:=xlTopToBottom, Header:=xlYes
End With
End Sub