Question : Sub that makes every pivot table item visible

How do I write the code below so that every item in my pivot table is made visible?

Thanks,
John
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
Sub ShowAll()
Application.ScreenUpdating = False
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Fault Type")
        .PivotItems("AUD").Visible = True
        .PivotItems("IFE").Visible = True
        .PivotItems("PSS").Visible = True
        .PivotItems("PWR").Visible = True
        .PivotItems("VID").Visible = True
    End With
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Fault Description")
        .PivotItems("ALL").Visible = True
        .PivotItems("AOD").Visible = True
        .PivotItems("CAL").Visible = True
        .PivotItems("ISP").Visible = True
        .PivotItems("RDL").Visible = True
        .PivotItems("TCH").Visible = True
        .PivotItems("VOD").Visible = True
    End With
    ActiveSheet.PivotTables("PivotTable1").PivotFields("Function Group"). _
        CurrentPage = "ALL"
Application.ScreenUpdating = True
End Sub

Answer : Sub that makes every pivot table item visible

[high maintenance askers...sheesh]

Sub ShowAll()
    Dim PivotTable As PivotTable
    Dim PivotField As PivotField
    Dim PivotItem As PivotItem
    Application.ScreenUpdating = False
    For Each PivotTable In ActiveSheet.PivotTables
        For Each PivotField In PivotTable.PivotFields
            For Each PivotItem In PivotField.PivotItems
                On Error Resume Next
                PivotItem.Visible = True
                On Error GoTo 0
            Next PivotItem
        Next PivotField
    Next PivotTable
    ActiveSheet.PivotTables("PivotTable1").PivotFields("Function Group").CurrentPage = "ALL"
    Application.ScreenUpdating = True
End Sub

Kevin
Random Solutions  
 
programming4us programming4us