Hello there,
I have recorded the following code that sorts from left to right. How do you make the hard coded ranges ("A1:EX1") (columns) and ("A1:EX1193") (rows) variable?
Sub RecordedMacro()
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A1:EX1") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:EX1193")
.Header = xlGuess
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
End Sub
Regards,
shinobi
Bookmarks