Dazzawm
Well-known Member
- Joined
- Jan 24, 2011
- Messages
- 3,786
- Office Version
- 365
- Platform
- Windows
I have this section of code that I recorded, how do I change it to the used range so it can be used on different files that have different amount of rows and columns please?
Code:
Cells.Select
Sheets("Sheet1").Activate
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add(Range("C2:C611582"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = RGB(255, _
255, 0)
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add key:=Range( _
"A2:A611582"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:AZ611582")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With