I have an Excel pivot table on which I want to do just two things: (1) apply the Classic PivotTable layout, and (2) to not show Subtotals. To help me with the code, I recorded a macro. When running the macro, I get the "Run-time error '1004': Unable to get the PivotTable property of the Worksheet class."
The pivot table is created manually. Then I switch to the Pivot and try to run the code.
With ActiveSheet.PivotTables("PivotTable1")
.InGridDropZones = True
.RowAxisLayout xlTabularRow
End With
ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"A" _
).Subtotals = Array(False, False, False, False, False, False, False, False, False, False _
, False, False)
ActiveSheet.PivotTables("PivotTable1").PivotFields("B").Subtotals _
= Array(False, False, False, False, False, False, False, False, False, False, False, False _
)
My expectation is that the code applies the Classic PivotTable layout, and then to remove any subtotals there may be.