Found this code in another thread and it seems to work great with a mock-up spreadsheet but isn't working on the spreadsheet I desperately need it to work on. I'm on Excel 2010 and have a sheet with ~100 pivot tables and I want them all to had the same fields visible.
Any thoughts on why this might not be working for me?
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim ptTable As PivotTable, ptItem As PivotItem, strField As String, boolMulti As Boolean
On Error GoTo ExitPoint
strField = "FIELD 1"
boolMulti = Target.PivotFields(strField).EnableMultiplePageItems
Application.EnableEvents = False
For Each ptTable In ActiveSheet.PivotTables
If ptTable <> Target Then
With ptTable.PivotFields(strField)
.ClearAllFilters
Select Case boolMulti
Case False
.CurrentPage = Target.PivotFields(strField).CurrentPage.Value
Case True
.CurrentPage = "(All)"
For Each ptItem In Target.PivotFields(strField).PivotItems
.PivotItems(ptItem.Name).Visible = ptItem.Visible
Next ptItem
.EnableMultiplePageItems = boolMulti
End Select
End With
End If
Next ptTable
ExitPoint:
Application.EnableEvents = True
End Sub
Bookmarks