How to cycle through pivot table column labels?

R

RADO

I need to cycle through all visible labels in pivot table columns. I tried
to use this code:

Set pt = Sheets("Table").PivotTables(1)

For Each pf In pt.ColumnFields
For Each pi In pf.PivotItems
With pi.LabelRange.Interior
.ColorIndex = 25
End With
Next pi
Next pf

If all items are visible, it works fine, but hidden items cause error. I am
trying to avoid using error handler. Anybody knows a better way?

Thanks much -
RADO
 
B

BrianB

FWIW I tested your code in Excel 97 and it works correctly whether the
PT columns are hidden or not.
 

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