Hi,
I have a pivot table with two columns: Code and Quantity. I want to loop through the Quantity column and hide all values = 0. I can do this easily by incorporating this into my code:
However, I have a "(blank)" code in all pivot tables. I do this because occasionally there is no data to organize in a pivot table. Having a "(blank)" option will allow my code to work even when there's no data. Therefore, I want to keep blank visible at all times. The above code hides "(blank)", however.
The below code is what I've tried with no success. Any alterations to the below code or additional suggestions would be great!
Thanks!
I have a pivot table with two columns: Code and Quantity. I want to loop through the Quantity column and hide all values = 0. I can do this easily by incorporating this into my code:
Code:
pt.PivotFields("Code").PivotFilters.Add _
Type:=xlValueDoesNotEqual, DataField:=pt.PivotFields("Sum of Quantity"), Value1:=0
However, I have a "(blank)" code in all pivot tables. I do this because occasionally there is no data to organize in a pivot table. Having a "(blank)" option will allow my code to work even when there's no data. Therefore, I want to keep blank visible at all times. The above code hides "(blank)", however.
The below code is what I've tried with no success. Any alterations to the below code or additional suggestions would be great!
Code:
Set pf = pt.PivotFields("code")
For Each pi In pf.PivotItems
If pi.PivotFields("Sum of Quantity").Value = 0 Then
pi.Visible = False
Else
pi.Visible = True
End If
Next pi
End With
Thanks!