Hello,
I'm looking for help in updating my VBA so that I'm accounting for the last column with data. Here's what I have, and it works fine for static data, but the column changes each day (moves to the right in a dated table range). Is there a way to sort the last column containing data, using VBA, when the last column changes each day? Thanks in advance.
I'm looking for help in updating my VBA so that I'm accounting for the last column with data. Here's what I have, and it works fine for static data, but the column changes each day (moves to the right in a dated table range). Is there a way to sort the last column containing data, using VBA, when the last column changes each day? Thanks in advance.
VBA Code:
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add2 Key:=Range( _
"B5:B24"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A5:X24")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With