Hi everyone
This is my first attempt to write a VBA code as I have no prior experience and i would much appreciate your help and guidance!!
I am working with a pivot table that has 3 filters on it. I am interested that for one of the filters which refers to some figures to automatically select all figures and then deselect zero as I am calculating an average and the "0" figure will distort the calculation.
The actual pivot table is linked to a slicer and the slicer to various graphs. Every time I select a different product from the slicer the pivot table will obviously refresh and add new data to my pivot table. Hence I need a macro where it would automatically make sure that all data is re-selected and then de-select the zero.
Below all I wrote so far but I get an error message saying I need to assign object?
Sub ShowAllItemsOfPivotTable()
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Financials 2")
PivotItem.Visible = True
Select Case PivotItem.Name
Case "0"
PivotItem.Visible = False
End Select
End With
End Sub
I have attached the document for your reference.
Thank you in advance for any help you may provide!
Bookmarks