Dazzawm
Well-known Member
- Joined
- Jan 24, 2011
- Messages
- 3,786
- Office Version
- 365
- Platform
- Windows
I did the code below by recording and want a bit of it amended please. Where it says worksheets 'New' I would like that changed to the active sheet and where it says the range C2:C1262, A1:AY1262 etc I would like that changed to the used range of rows and columns as it will change each sheet I use it on.
Thanks.
Thanks.
Code:
Range("A1").Select
ActiveWorkbook.Worksheets("New").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("New").Sort.SortFields.Add2 key:=Range("C2:C1262"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("New").Sort.SortFields.Add2 key:=Range("A2:A1262"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("New").Sort
.SetRange Range("A1:AY1262")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With