View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Is it possible to build sort statement?

Try this with 3 columns
Sub Macro1()
Range("A:C").Sort Key1:=Range("A2"), Order1:=xlAscending, _
Key2:=Range("B2"), Order2:=xlAscending, _
Key3:=Range("C2"), Order3:=xlAscending, _
Header:=xlGuess, Orientation:=xlTopToBottom
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Norm" wrote:

I'd like to build a macro that does a number of user-specified things to a
file. One of them is to sort. The user would specify up to 3 columns to
sort. Can an Excel macro "build" the sort parameters? The following sure
doesn't work:

s = "Key1:=Range(""A2""), Order1:=xlAscending, " & _
"Key2:=Range(""B2""), Order2:=xlAscending, "
Range("A1:H6563").Sort s

Thanks for the help!