I recorded a macro to sort my worksheet, which starts out with 121 rows.
After clicking "record macro", I move to cell A1, then do "shift ctrl page down" to select column A. Then "shift ctrl end (right arrow)" to get my columns. I then enter my sort criteria (cols, D, A, B), and that's it.
I've pasted the code that gets generated below. Notice the hard cell references for "D2:D121", "A2:A121" and "B2:B121". However, if I add more rows, it looks like this will still only sort the first 121 rows.
How can I solve this?
Thanks!
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveWorkbook.Worksheets("February").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("February").Sort.SortFields.Add2 Key:=Range( _
"D2:D121"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("February").Sort.SortFields.Add2 Key:=Range( _
"A2:A121"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("February").Sort.SortFields.Add2 Key:=Range( _
"B2:B121"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("February").Sort
.SetRange Range("A1:H121")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
After clicking "record macro", I move to cell A1, then do "shift ctrl page down" to select column A. Then "shift ctrl end (right arrow)" to get my columns. I then enter my sort criteria (cols, D, A, B), and that's it.
I've pasted the code that gets generated below. Notice the hard cell references for "D2:D121", "A2:A121" and "B2:B121". However, if I add more rows, it looks like this will still only sort the first 121 rows.
How can I solve this?
Thanks!
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveWorkbook.Worksheets("February").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("February").Sort.SortFields.Add2 Key:=Range( _
"D2:D121"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("February").Sort.SortFields.Add2 Key:=Range( _
"A2:A121"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("February").Sort.SortFields.Add2 Key:=Range( _
"B2:B121"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("February").Sort
.SetRange Range("A1:H121")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With