I have to order and sort several workbooks of different column lengths and row amounts. I would like the script to be dynamic in the selection. The starting point will always be the same C1. The script is below and I have included “Selection” and “xlToRight” in the ranges. However, that does not work. I know nothing of VBA and am learning on the fly. Edit: I would like to sort on row 2 so C2 I believe.
Range("C1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveWorkbook.Worksheets("Matrix").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Matrix").Sort.SortFields.Add Key:=Range(Selection, Selection) _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Matrix").Sort
.SetRange Range("C1:xlToRight")
.Header = xlYes
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
2