RWayneH
asked on
Pivot Table, deselecting a field
The following code deselects it from a pivot table. What happens if it is not there to deselect? Is there a way to rewrite this so whether it is, or is not there is will deselect it?
ActiveSheet.PivotTables("PivotTable4").PivotFields("Ship To Name").CurrentPage _
= "(All)"
With ActiveSheet.PivotTables("PivotTable4").PivotFields("Ship To Name")
.PivotItems("Haworth Holland Customer CPU ").Visible = False
End With
ActiveSheet.PivotTables("PivotTable4").PivotFields("Ship To Name"). _
EnableMultiplePageItems = True
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Rgonzo1971 suggestion did not work, unless he was referring to put it into the error handler?
Question on the: On Error what does the on error goto 0 do? Is the zero no where? or a position?
I have used goto 100 or goto 200 but they have always referred to a different place in the procedure
Question on the: On Error what does the on error goto 0 do? Is the zero no where? or a position?
I have used goto 100 or goto 200 but they have always referred to a different place in the procedure
It just clears the error handler - i.e. cancels the On Error Resume Next.
ASKER
Thanks for the help.
With ActiveSheet.PivotTables("P
.PivotItems("Haworth Holland Customer CPU ").Visible = False
End With
then try
set myItem = ActiveSheet.PivotTables("P
.PivotItems("Haworth Holland Customer CPU ")
If Not myItem Is Nothing Then myItem.Visible = False
Regards