Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read Pivotitem propertie to a variable

Status
Not open for further replies.

ETID

Programmer
Jul 6, 2001
1,867
US
Hi fellow VBA Dabblers,...

Does anyone know how to return if a pivot item is hidden via vba?
This code runs but returns false even though many are true
------------------------------


Sub Pivot_Items_Selected()

Dim PvtItemName As String

With ActiveSheet.PivotTables("PivotTable2").PivotFields("MY_FIELD")
For i = 1 To .PivotItems.Count
PvtItemName = .PivotItems(i).Name
If .PivotItems(PvtItemName).Visible = False Then
Debug.Print .PivotItems(i).Name
Else
End If
Next
End With

End Sub
 
Got it

This code from excelforum.com does the trick if anyone needs to know......

Sub PageItemsHidden()
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Dim piCurr As String

Set pt = ActiveSheet.PivotTables(1)
Set pf = pt.PivotFields("MY_FIELD")
piCurr = pf.CurrentPage
For Each pi In pf.PivotItems
On Error Resume Next
pf.CurrentPage = pi.Name
Debug.Print pi.Name & " - " & pi.Visible
Next pi
pf.CurrentPage = piCurr
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top