I'm trying to sort a table, but the bottom of the table will vary. I can't set it lower than the bottom data in Column A. I am defining my variable as the bottom Row in column A, but I can't figure out how to get it to work inside the sort code.
Variable = Range("A" & Rows.Count).End(xlUp).Row
ActiveWorkbook.Worksheets(dataSht).AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets(dataSht).AutoFilter.Sort.SortFields.Add Key:= _
Range("L9:L"Variable) SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets(dataSht).AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Bookmarks