Hi all,
I am working on this sheet and I need a lot of data to be sorted in a specific manner. The only issue is that the data I use changes. One week I may have 5000 rows of data in Excel, and others I may have 6000. Is there a way to make the sorta range in this code here change based on how many rows there are?
In the code above I tried changing all of the "A1:AW7000" to "Cells.Select" but that didn't work. All help is appreciated, thanks!
I am working on this sheet and I need a lot of data to be sorted in a specific manner. The only issue is that the data I use changes. One week I may have 5000 rows of data in Excel, and others I may have 6000. Is there a way to make the sorta range in this code here change based on how many rows there are?
Code:
Cells.Select ActiveWorkbook.Worksheets("REPORT").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("REPORT").Sort.SortFields.Add2 Key:=Range( _
"A1:AW7000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("REPORT").Sort.SortFields.Add2 Key:=Range( _
"A1:AW7000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("REPORT").Sort.SortFields.Add2 Key:=Range( _
"A1:AW7000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("REPORT").Sort
.SetRange Range("A1:AW7000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
In the code above I tried changing all of the "A1:AW7000" to "Cells.Select" but that didn't work. All help is appreciated, thanks!