| Member with 3 posts. THREAD STARTER | | Join Date: Jun 2012 Experience: Beginner | |
Solved: How to execute a macro across a specific number of columns Hello,
I am trying to learn rules in altering a macro that has been recorded. I need the following code to execute across columns A-AX, where each column is to be sorted independently of the others. Thank you in advance for your time. Code: Range("A2:AX21").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A2"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A2:A21")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub |