Hi!
I am using the following VBA to transfer the pivot filters to other tables. This code is designed to handle/transfer one single pivot filter field, but I need 3 fields.
I have another VBA which changes all fields but due to performance issues not an option. Slicers are not an option as well.
How can I amend this VBA to handle 3 fields?
Option Explicit
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
On Error Resume Next
Dim wsMain As Worksheet
Dim ws As Worksheet
Dim ptMain As PivotTable
Dim pt As PivotTable
Dim pfMain As PivotField
Dim pf As PivotField
Dim pi As PivotItem
Dim bMI As Boolean
On Error Resume Next
Set wsMain = ActiveSheet
Set ptMain = Target
Application.EnableEvents = False
Application.ScreenUpdating = False
'change only Region field for all pivot tables on active sheet
Set pfMain = ptMain.PivotFields("Region")
bMI = pfMain.EnableMultiplePageItems
For Each pt In wsMain.PivotTables
If pt <> ptMain Then
pt.ManualUpdate = True
Set pf = pt.PivotFields("Region")
bMI = pfMain.EnableMultiplePageItems
With pf
.ClearAllFilters
Select Case bMI
Case False
.CurrentPage = pfMain.CurrentPage.Value
Case True
.CurrentPage = "(All)"
For Each pi In pfMain.PivotItems
.PivotItems(pi.Name).Visible = pi.Visible
Next pi
.EnableMultiplePageItems = bMI
End Select
End With
bMI = False
Set pf = Nothing
pt.ManualUpdate = False
End If
Next pt
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Bookmarks