error 1004 - Unable to set the visible property of the PivotItem class

ExcelEveryday1

New Member
Joined
Jan 7, 2016
Messages
20
Good Morning,

I keep getting the error that is mentioned in the title when trying to hide a filter in my pivottable. I've googled possible solutions, but i cant figure out how to fix this...

I have code previous to this which enables the "A" filter on all my pivots, however I need to hide it in some cases. Excel wont let me hide it :(.

Relevant code is the following:

Code:
For x = 4 To 5


Sheets("page " & x).Activate

 ActiveSheet.PivotTables("PivotPage" & x).PivotFields("Umbrella").Orientation = _
        xlHidden
    With ActiveSheet.PivotTables("PivotPage" & x).PivotFields("Umbrella")
        .Orientation = xlPageField
        .Position = 3
    End With
    ActiveSheet.PivotTables("PivotPage" & x).PivotFields("Umbrella").CurrentPage = _
        "(All)"
    With ActiveSheet.PivotTables("PivotPage" & x).PivotFields("Umbrella")
        .PivotItems("A").Visible = False
        .PivotItems("B").Visible = True
    End With

next x

Thanks for your help!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top