Total disclosure - I am out of my depth here! I'm editing a macro a made with VBA editor and I need to get column W to sort by values highest to lowest. The "header" in column W starts at W8 and the first row of actual data is from W9 downwards. I do want to entire worksheet to resort just as it would have done had I used the filter arrow on the column header to o the same thing (presuming I had filter arrows on all the columns which I do). The thing is that this macro is to be run on an input template which gets updated once a month and every month new rows are added so I need to be able to make sure the sort gets applied from W9 to the last row of data (whatever that may be on that particular month).
I hardly dare post my awful attempt at the code - I just have something which I can confirm doesn't work!
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table1345").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table1345").Sort.SortFields. _
Add Key:=Range("Table1345[[#All],[Reporting_Period_Total]]"), SortOn:= _
xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table1345").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With