G
Glen Mettler
I want to sort a section of a spreadsheet -
I make a selection (say range("A22
27")
I then want to sort that selection on column c then column d
when I recorded the macro this is what I got:
Range("A22
27").Select
Selection.Sort Key1:=Range("C22"), Order1:=xlAscending,
Key2:=Range("D22" _
), Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False _
, Orientation:=xlTopToBottom
The problem is that the range is hard coded with "C22" - I want a variable
so I can select a range and then sort by column c then column d
How can I capture the top row number of the range so I can have this as a
dynamic macro?
Glen
I make a selection (say range("A22
I then want to sort that selection on column c then column d
when I recorded the macro this is what I got:
Range("A22
Selection.Sort Key1:=Range("C22"), Order1:=xlAscending,
Key2:=Range("D22" _
), Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False _
, Orientation:=xlTopToBottom
The problem is that the range is hard coded with "C22" - I want a variable
so I can select a range and then sort by column c then column d
How can I capture the top row number of the range so I can have this as a
dynamic macro?
Glen