Hi, I'm trying to use a macro that sorts data in multiple columns.
However, upon viewing the code after recording the macro, I notice a range has been declared (to row 483).
Issue with the below code is the ranges only go to row 483. Next week it may be 500+ etc
Original recorded Macro
My attempt below:
However, upon viewing the code after recording the macro, I notice a range has been declared (to row 483).
Issue with the below code is the ranges only go to row 483. Next week it may be 500+ etc
Original recorded Macro
VBA Code:
Cells.Select
ActiveWorkbook.Worksheets("Oct data").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Oct Data").Sort.SortFields.Add2 Key _
:=Range("A2:A483"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Oct Data").Sort.SortFields.Add2 Key _
:=Range("R2:R483"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Oct Data").Sort
.SetRange Range("A1:AV483")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.Run "ConnectChartEvents"
Sheets("Oct Data").Select
My attempt below:
VBA Code:
Dim lastA As Long
ActiveWorkbook.Worksheets("Oct Data").Sort.SortFields.Add2 Key _
:=Range("A1:A" & lastA), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal