I have a sort macro that I've recorded and want to use it on various worksheets (one at a time upon activation) with in a workbook. The sort macro has the worksheet name of the worksheet at the time of the recording and so I'm not able to use it for other worksheets in the workbook (e.g. Catalina). I would like to make the macro flexible so the sort will work on any active worksheet I select in the workbook.
I'm relatively new at this and would appreciate a bit of direction.
Thanks in advance.
JJT
The recoded code
I'm relatively new at this and would appreciate a bit of direction.
Thanks in advance.
JJT
The recoded code
VBA Code:
'
ActiveCell.Range("A1:J151").Select
ActiveWorkbook.Worksheets("Catalina").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Catalina").AutoFilter.Sort.SortFields.Add2 Key:= _
ActiveCell.Range("A1:A150"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Catalina").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Last edited by a moderator: