ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Sorting of data (https://www.excelbanter.com/excel-worksheet-functions/182062-sorting-data.html)

UB

Sorting of data
 
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.


ND Pard

Sorting of data
 
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.

"ub" wrote:

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.


UB

Sorting of data
 
Hi
Can you please advise how the formula will be written.

"ND Pard" wrote:

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.

"ub" wrote:

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.



All times are GMT +1. The time now is 04:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com