default_name
Board Regular
- Joined
- May 16, 2018
- Messages
- 170
- Office Version
- 365
- 2016
- Platform
- Windows
- MacOS
I have seen several examples of multi-level sorting online, but I am struggling to find a method that works best for my needs.
I am trying to sort all of the data on sheet1 (the data spans from columns A to R).
Here is what I currently have (including the order in which I am trying to sort the data on):
I get an error when I attempt this. I have stepped through it and am realizing that it only works with 3 keys. I need it to work with 5.
I tried simply copying the code again with my remaining 2 columns, but that didnt work out so well. I need to sort all of the data together.
How can I make this work?
Thanks in advance
I am trying to sort all of the data on sheet1 (the data spans from columns A to R).
Here is what I currently have (including the order in which I am trying to sort the data on):
VBA Code:
Sheets("sheet1").Range("A1:R" & Sheets("sheet1").Range("A1").End(xlDown).Row).Sort _
key1:=Sheets("sheet1").Range("A:A"), order1:=xlAscending, _
key2:=Sheets("sheet1").Range("G:G"), order2:=xlAscending, _
key3:=Sheets("sheet1").Range("F:F"), order3:=xlAscending, _
key4:=Sheets("sheet1").Range("B:B"), order4:=xlAscending, _
key5:=Sheets("sheet1").Range("M:M"), order5:=xlAscending, _
Header:=xlYes
I get an error when I attempt this. I have stepped through it and am realizing that it only works with 3 keys. I need it to work with 5.
I tried simply copying the code again with my remaining 2 columns, but that didnt work out so well. I need to sort all of the data together.
How can I make this work?
Thanks in advance