how do I sort more than 3 columns?


Posted by Stacy on March 26, 2001 2:12 PM

Right now I have the following code to sort. If I try and manipulate it to add a 4th sort I get an error. Is there a way to add 4 to this...or do I have to totally re-write it another way. Thanks in advance!!


Sheets("Sheet1").Activate
Range("B10").Select
Selection.sort Key1:=Range("H7"), _
Order1:=xlAscending, _
Key2:=Range("B7"), _
Order2:=xlAscending, _
Key3:=Range("C7"), _
Order3:=xlAscending, _
Header:= _
xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom


Posted by Mark W. on March 26, 2001 2:29 PM

Stacy, you'll have to make multiple passes thru
the data.



Posted by Dave Hawley on March 27, 2001 5:17 PM


Hi Stacy

Give this code a run!


Sub TyThis()
With Sheets("Sheet1").Range("B7")

.CurrentRegion.Sort Key1:=.Range("H7"), _
Order1:=xlAscending, _
Key2:=.Range("B7"), _
Order2:=xlAscending, _
Key3:=.Range("C7"), _
Order3:=xlAscending, _
Header:=xlYes, _
Orientation:=xlTopToBottom

.CurrentRegion.Sort Key1:=Range("A7")

End With


End Sub


Dave

OzGrid Business Applications