I am receiving this error:
Run-time error '1004' Unable to get PivotFields property of the PivotTable class
This is occurring for me in Excel VBA (version 2013), but the same code executes successfully on a different machine running Office 365.
This successfully prints the name of the pivot table, but gives the same error when it hits this line:
I tried by recording a macro and changing a filter in the PivotTable. The recorded macro fails on the following line:
Please let me know if anyone has insight into why the PivotFields property might be unavailable to my application or any ideas for troubleshooting.
Run-time error '1004' Unable to get PivotFields property of the PivotTable class
This is occurring for me in Excel VBA (version 2013), but the same code executes successfully on a different machine running Office 365.
Code:
With pt
.PivotFields(fieldName).ClearLabelFilters
.PivotFields(fieldName).PivotFilters.Add Type:=xlCaptionEquals, Value1:=strFilter
End With
In order to ensure I was naming the pivot fields correctly, I tried looping through the pivot table to get the names of all the pivot tables and fields:
Dim pt As PivotTable
Dim pf As PivotField
wb.Worksheets("Sheet1").Activate
For Each pt In wb.Worksheets("Sheet1").PivotTables
Debug.Print pt.Name
For Each pf In pt.PivotFields
Debug.Print pf.Name
Next pf
Next pt
Code:
For Each pf In pt.PivotFields
Code:
ActiveSheet.PivotTables("testPivotTable").PivotFields("TYPE").ClearAllFilters
Last edited by a moderator: