Sort By More Than 3 Columns
-
-
-
Re: Fourth Criteria For Sort
You could concatenate the 3rd and the 4th column into a 5th column. Then sort everything on columns 1, 2, 5 and delete column 5.
Wigi
-
Re: Fourth Criteria For Sort
Sort by more than 3 Columns
Excels sort feature only allows to nominate up to 3 columns to sort by, here is how to get around this. The key to this is sorting by the last key first and working back to the first key. Say you data is in Column A:E and you want to sort by A, B, C , D then E1. Select all of Columns A:E
2. Go to Data>Sort> sort by C then by D then by E
3. Click Sort
4. Now again with Columns A:E selected
5. Go to Data>Sort> sort by A then by B
6. Click Sort -
Re: Sort By More Than 3 Columns
If you want to use a macro this will sort 5 columns for you when the sheet is activated.
Code
Display MorePrivate Sub Worksheet_Activate() Range("A2", Range("F65536").End(xlUp).Address).Select Selection.Sort Key1:=Range("B2"), Order1:=xlDescending _ , Key2:=Range("C2"), Order2:=xlDescending _ , Key3:=Range("D2"), Order3:=xlDescending Selection.Sort Key1:=Range("E2"), Order1:=xlDescending _ , Key2:=Range("F2"), Order2:=xlDescending _ End Sub
Hope this helps
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!