Multiple pivot table problem

tommy1234

New Member
Joined
Aug 24, 2011
Messages
20
Hello

i have a 2 sheets.
the first contain the main pivot table and the second contain many pivot table.
all the pivot table created from the same data base.
i want to filter fields in the main pivot table and after that all the other pivot table will be filtered with same value as the main pivot.
i succeed to find a code to do want i want, but the problem is the the filter works only for one value and i need to choose multiple values.
can some help me to solve the problem
thank you

[VBA]
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
On Error Resume Next
Dim Ws As Worksheet
Dim wsMain As Worksheet
Dim ptMain As PivotTable
Dim Pt As PivotTable
Dim pfMain As PivotField
Dim Pi As PivotItem
Dim pf As PivotField

On Error Resume Next
Set wsMain = Sheets("Sales")
Set ptMain = Target

Application.EnableEvents = False
Application.ScreenUpdating = False

For Each pfMain In ptMain.PageFields
For Each Ws In ThisWorkbook.Worksheets
If Ws.Name <> wsMain.Name Then
For Each Pt In Ws.PivotTables
Pt.RefreshTable
For Each pf In Pt.PageFields
If pf.Name = pfMain.Name Then
If pfMain.CurrentPage = "(All)" Then
pf.CurrentPage = "(All)"
Exit For
End If
For Each Pi In pf.PivotItems
If Pi.Name = pfMain.CurrentPage Then
pf.CurrentPage = Pi.Name
Exit For
End If
Next Pi
End If
Next pf
Next Pt
End If
Next Ws
Next pfMain

Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub

[/VBA]
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,224,518
Messages
6,179,248
Members
452,900
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top