Thread: Many Sort Keys
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.newusers
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Many Sort Keys

Just as in XL's Sort command, you can only sort 3 columns at a time, so
sort the 4th column first, then the other three. Try:


Public Sub SortMe()
Cells.Sort Key1:=Range("D1"), Header:=xlYes
Cells.Sort Key1:=Range("F1"), Key2:=Range("B1"), _
Key3:=Range("C1"), Header:=xlYes
End Sub


In article om,
wrote:

Is there a way to have a macro written to include many sort keys? The
one I have now sorts for 3 things - but it seems when I try to sort
for 4, it gives me an error?

This is what I currently have:

Sub SortMe()

Cells.Sort Key1:=Range("F1"), Key2:=Range("B1"),
Key3:=Range("C1"), Header:=xlYes

End Sub


I tried just adding in to make it:

Sub SortMe()

Cells.Sort Key1:=Range("F1"), Key2:=Range("B1"),
Key3:=Range("C1"), Key4:=Range("D1"), Header:=xlYes

End Sub

But it says "Named Argument Not Found"... am I doing something wrong?

Can someone help??

(I didn't write the macro - someone else just told me what to put and
where it went!)

Thanks :)