ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamic Sort (https://www.excelbanter.com/excel-programming/272865-dynamic-sort.html)

bw

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




All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com