Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting data in Excel with more than 3 keys. 1

Status
Not open for further replies.

AgatheB

Programmer
Jan 16, 2003
36
DK
Is it possible to sort data with 4 keys?
I've tried:
.Range(.Rows(pRow1), .Rows(Rowx - 1)).Sort _
key1:=.Columns(pCol_ID1), key2:=.Columns(pCol_ID2) _
, key3:=.Columns(pCol_ID3), key4:=.Columns(pCol_ID4)
but that won't do the trick.

Any suggestions?

Agathe
 
Nope - max of 3 keys - if you want to do this, easiest way round is to create an extra field (hide the column if necessary) which concatenates the 4 entries you want to sort on and then use that field to sort on

Rgds
Geoff
Si hoc legere scis, nimis eruditionis habes
 
Actually you can sort by more than 3 keys, you just have to do it in steps of 3 or less at a time:

Code:
.Range(.Rows(pRow1), .Rows(Rowx - 1)).Sort _
    key1:=.Columns(pCol_ID4)
.Range(.Rows(pRow1), .Rows(Rowx - 1)).Sort _
    key1:=.Columns(pCol_ID1), key2:=.Columns(pCol_ID2) _
    , key3:=.Columns(pCol_ID3)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top