remove/delete/hide/exclude all (Blanks) in a pivot table macro

M

mju

Below is a sample of my code to remove all (blanks) in a pivot table.

With ActiveSheet.PivotTables("PivotTable1").PivotFields("TRAD_PARTNER ")
.PivotItems("(blank)").Visible = False
End With
it works fine it there balnks in the pivot table.
However, sometimes if the data set does not have any (blank), the macro
generates a Run-time 1004 error. (Unable to get the PivotItems Property of
the PivotField class)
Is there a that i can skip the code if there are no (blank)?
I tried If statement but it did not work.

Thanks alot people:)-
 
B

Bob Umlas

On Error Resume Next
With ActiveSheet.PivotTables("PivotTable1").PivotFields("TRAD_PARTNER ")
.PivotItems("(blank)").Visible = False
End With

Bob Umlas
Excel MVP
 
M

mju

thanks Alot!!!!

Bob Umlas said:
On Error Resume Next
With ActiveSheet.PivotTables("PivotTable1").PivotFields("TRAD_PARTNER ")
.PivotItems("(blank)").Visible = False
End With

Bob Umlas
Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top