Thread: Dynamic Sort
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
bw bw is offline
external usenet poster
 
Posts: 74
Default Dynamic Sort

How do I change the following code to sort by a parameter SortCol1 and SortCol2, which
contains the column identifiers by which I want to sort? For example, SortCol1 = 3 (or
"C" if if would be better), SortCol2 = 1 (or "A" if if would be better)...

Cells.Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("A2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal

Thanks,
Bernie