PivotField select all

C

CinqueTerra

I would like to show all items in PivotFields("PERIOD_NUMBER"). Following is
my code:

Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem

Set pt = Sheets("Pivot2").PivotTables("pvtWageRptCGFS")
Set pf = pt.PivotFields("PERIOD_NUMBER")

For Each pi In pf.PivotItems
pi.Visible = True
Next pi

Problem: I get run time error '1004' Unable to set the Visible Property of
the Pivot Item Class on "pi.Visible = True"

Thanks in advance for any help!
 
T

tlaw37

CinqueTerra said:
I would like to show all items in PivotFields("PERIOD_NUMBER"). Following is
my code:

Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem

Set pt = Sheets("Pivot2").PivotTables("pvtWageRptCGFS")
Set pf = pt.PivotFields("PERIOD_NUMBER")

For Each pi In pf.PivotItems
pi.Visible = True
Next pi

Problem: I get run time error '1004' Unable to set the Visible Property of
the Pivot Item Class on "pi.Visible = True"

Thanks in advance for any help!

One cause is having an autosort designated in Field Settings,
Advanced. Autosort must be manual before the Visible property can be
set. Something like

pf.AutoSort xlManual, "PERIOD_NUMBER"

before the for loop is entered.

Tom
 
C

CinqueTerra

Awesome! Thanks :)

One cause is having an autosort designated in Field Settings,
Advanced. Autosort must be manual before the Visible property can be
set. Something like

pf.AutoSort xlManual, "PERIOD_NUMBER"

before the for loop is entered.

Tom
 

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