I recorded this macro to sort a pivot table.
However, the pivot table is dynamic, and this macro only works if the pivot table ends in the correct column (k).
Is there a way to make it so the macro affects the last column with data in it?
On Error GoTo ErrorHandler
ErrorHandler:
Resume Next
Range("K4").Select
ActiveSheet.PivotTables("InventoryPivotTable").PivotFields("Products"). _
AutoSort xlAscending, "FBM ", ActiveSheet.PivotTables("InventoryPivotTable"). _
PivotColumnAxis.PivotLines(8), 1
ActiveWorkbook.ShowPivotTableFieldList = False
Call highlightNegativeNumbersFBM