Sorting of data

  • Thread starter Thread starter ub
  • Start date Start date
U

ub

Hi
I have to sort the data in my excell sheet. I have to sort my data using 4
keys.
Excell sort functios allows sorting by 3 values.
I tried writing a VBA code but it only excepts 3 keys.
Worksheets("sheet").Range("a1:ba67").Sort _
Key1:=Worksheets("sheet").Range("c1"), order1:=xlAscending, _
Key2:=Worksheets("sheet").Range("e1"), order1:=xlAscending, _
Key3:=Worksheets("sheet").Range("f1"), order1:=xlAscending

Is it possible to sort using 4rth key also.

Thanks in advance.
 
Add a new column and concatenate the 4 unique columns in the proper sort order.

For example if you want Columns B, C, D and E to be sorted first by column
D, then B, then E and finally C; in the new column put the contatenate
formula:

+D2&B2&E2&C2

Copy the formula down and sort on the new column.

I hope that helps. Good Luck.
 
Back
Top