I am trying to use the following macro to automatically update a pivot table when something changes (just the barebones changes below) :
However, none of the commented code works when I try each line separately. I keep getting errors like "Unable to set the CurrentPage Property of the PivotField Class". As noted in title, this is a filter within a column (only want to pull current month this year and last.) Also, it's powered by a PowerPivot Model. Not sure if this is an issue as well.
Code:
Dim pf As PivotField
Dim pt As PivotTable
Set pt = Sheets("Top 10 Pivots").PivotTables("TotalUS")
Set pf = pt.PivotFields("[MonthOnlyDateTable].[Fiscal Month].[Fiscal Month]")
'pf.CurrentPage = "2018 / 10"
'pf.ClearAllFilters
However, none of the commented code works when I try each line separately. I keep getting errors like "Unable to set the CurrentPage Property of the PivotField Class". As noted in title, this is a filter within a column (only want to pull current month this year and last.) Also, it's powered by a PowerPivot Model. Not sure if this is an issue as well.