Range("A3:F50").Select
ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Range("F3:F50") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.Sort
.SetRange Range("A2:F50")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
My code was hard coded to sort on Column F, and I just guessed by going to row 50 that it would go past my actual data. Today it failed and I realized it failed because my raw data had an extra column. The column I need to sort on is "Grand Total". Because of the extra column, it was now Column G instead of F. So apparently it may not be consistently in the same place. So can I include a FIND in the range selection? Also include something that looks for the last row of data?
Bookmarks