D
DynamiteSkippy
I really hope someone can help me with this. I am trying to make visible a
specified Pivot Item within a specific PivotField within a specific Pivot
Table. I have been trying to adapt some code to hide all Pivot Items for all
RowFields for all PivotTables but I haven't been very successful at it. Any
help I could get would be greatly appreciated.
Sub Shell()
Run SpecPivotItemsVisible("PivotTable6", "Country", "US")
End Sub
Sub SpecPivotItemsVisible(PivotTbl As String, PivField As String, PivItem As
String)
'hide all pivot items in all tables on sheet
'except last item
Dim pt As PivotTable 'Pivot table
Dim pf As PivotField 'Pivot field
Dim pi As PivotItem ' specific pivot item
Dim opi As PivotItem 'other pivot items
pt = Worksheets("Hidden).PivotTables(PivotTbl).value
pf = pt.PivotFields(PivField)
pi = pf.PivotItems(PivItem)
On Error Resume Next
With Worksheets("Hidden").PivotTables(pf)
RowField("gee").AutoSort xlManual
For Each opi = not pi In PivotField("pf").PivotItems
pi.Visible = False
Next
RowField("pf").AutoSort xlManual
End With
End Sub
specified Pivot Item within a specific PivotField within a specific Pivot
Table. I have been trying to adapt some code to hide all Pivot Items for all
RowFields for all PivotTables but I haven't been very successful at it. Any
help I could get would be greatly appreciated.
Sub Shell()
Run SpecPivotItemsVisible("PivotTable6", "Country", "US")
End Sub
Sub SpecPivotItemsVisible(PivotTbl As String, PivField As String, PivItem As
String)
'hide all pivot items in all tables on sheet
'except last item
Dim pt As PivotTable 'Pivot table
Dim pf As PivotField 'Pivot field
Dim pi As PivotItem ' specific pivot item
Dim opi As PivotItem 'other pivot items
pt = Worksheets("Hidden).PivotTables(PivotTbl).value
pf = pt.PivotFields(PivField)
pi = pf.PivotItems(PivItem)
On Error Resume Next
With Worksheets("Hidden").PivotTables(pf)
RowField("gee").AutoSort xlManual
For Each opi = not pi In PivotField("pf").PivotItems
pi.Visible = False
Next
RowField("pf").AutoSort xlManual
End With
End Sub