Hi I'd like to automate excels inbuilt sort / subsort for a non static range of cells ...
The range is based on
5 columns including and adjacent to the selected cell and say 66 rows down ...
Ie . EV4:EZ70
The initial range being sorted alphabetically by cells EY4:EY70
Then a subsort numerically EW4:EW70
Only to sort cells in the range that have values in EV4:EV70...
When I record a macro I get this ??
Any help is appreciated ! Thanks
The range is based on
5 columns including and adjacent to the selected cell and say 66 rows down ...
Ie . EV4:EZ70
The initial range being sorted alphabetically by cells EY4:EY70
Then a subsort numerically EW4:EW70
Only to sort cells in the range that have values in EV4:EV70...
When I record a macro I get this ??
Code:
Sub sortexample()
'
' sortexample Macro
'
'
Range("EV4:EZ70").Select
ActiveWorkbook.Worksheets("Period 12").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Period 12").Sort.SortFields.Add Key:=Range( _
"EY4:EY70"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Period 12").Sort.SortFields.Add Key:=Range( _
"EW4:EW70"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Period 12").Sort
.SetRange Range("EV4:EZ70")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWindow.SmallScroll Down:=-48
Any help is appreciated ! Thanks
Last edited by a moderator: