Sorting of data

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.
 
N

ND Pard

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top