Hi,
I am trying to create a script that will change the filtered date to the date a week ago when I cue the macro. Posted below is the code I came up with, but it is giving me a run time error. Any suggestions would be much appreciated.
I am trying to create a script that will change the filtered date to the date a week ago when I cue the macro. Posted below is the code I came up with, but it is giving me a run time error. Any suggestions would be much appreciated.
Code:
Sub PivotTableFilter()
Dim PvtTbl As PivotTable
Set PvtTbl = Worksheets("CWTPIVOT").PivotTables("PivotTable1")
PvtTbl.PivotFields("SUM_END_DATE").PivotFilters.Add Type:=xlDateLastWeek
End Sub