ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to cycle through pivot table column labels? (https://www.excelbanter.com/excel-programming/281538-how-cycle-through-pivot-table-column-labels.html)

RADO[_3_]

How to cycle through pivot table column labels?
 
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



BrianB

How to cycle through pivot table column labels?
 

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


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



All times are GMT +1. The time now is 09:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com