Error:"Unable to Set Visible Property PivotItem class"

Article translations Article translations
Article ID: 114822 - View products that this article applies to.
This article was previously published under Q114822
Expand all | Collapse all

SYMPTOMS

When you run a recorded Visual Basic, Applications Edition, macro to set up a pivot table in which discontiguous items are hidden in the PivotTable Field dialog box, you may receive the following error message:
Unable to set the Visible property of the PivotItem class

CAUSE

Only contiguous items in a PivotTable Field can be hidden.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel for Windows version 5.0c.

WORKAROUND

To work around this problem, remove or disable (use an apostrophe to comment out) the line or lines that set the visible property of discontiguous items in the field to False; removing or disabling this line will allow your macro to run successfully.

For example, in the following code, you would comment out the fourth line down to disable the code that causes the error:
   With ActiveSheet.PivotTables("PivotTable1").PivotFields("field1")
        .PivotItems("1").Visible = False
        .PivotItems("2").Visible = False
       '.PivotItems("7").Visible = False
   End With
				

Properties

Article ID: 114822 - Last Review: October 11, 2006 - Revision: 1.3
APPLIES TO
  • Microsoft Excel 5.0 Standard Edition
Keywords: 
kbprogramming KB114822
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com