Run Time Error 1004, Unable to set visible property in Pivotitem Class

J

John

I had posted this earlier, and gotten a reply from Tom
saying that I needed to change my sort to manual. The
thing is is that I am not sorting anything. this is what
my code looks like

Sub SelectALL()
With ActiveSheet.PivotTables("PivotTable4").PivotFields
("Analyst")
.PivotItems("E, F").Visible = False
.PivotItems("X, Y").Visible = False
End With
With ActiveSheet.PivotTables("PivotTable4").PivotFields
("Analyst")
.PivotItems("E, F").Visible = True
.PivotItems("X, Y").Visible = True
End With
End Sub

I initially hide everything in the pivottable, and then
select the ones i want to be displayed. the hides works
fine, but i get my run time error when it tries to
set .visible = true. Any thoughts would be greatly
appreciated, THANK YOU
 
T

Tom Ogilvy

I didn't say you had to sort anything. this is a setting for the pivot
table.

Apparently it won't let you unhide pivotitems programmatically if this
setting isn't set to manual.

If you set it to manual as advised, then you should be successful (assuming
your code it correct). If not, then if this is the cause of failure as
Debra has stated, then you won't be unhidding pivotitems.
 

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