Pivot Items

G

Guest

Hi
I would like to know what code should I write to hide all the PivotItems a
PivotField might have instead of writing a line of code for each PivotItem
like this:
Worksheets("sheet3").PivotTables(1) _
.PivotFields("year").PivotItems("1998").Visible = False

Regards,
Pedro
 
T

Tom Ogilvy

Dim pvtItm as PivotItem, i as Long
i = 0
for each pvtItm in Worksheets("sheet3").PivotTables(1) _
.PivotFields("year").Items
if i <> 0 then
pvtItm.visible = False
else
pvtItm.Visible = True
end if
i = i + 1
Next

However, at least one item has to remain visible I believe. (Thus I don't
hide the first one in the above).

Debra Dalgleish's site has some good information on programming Pivot
Tables:
http://www.contextures.com/tiptech.html
 

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