Filter multiple pivot tables based on 1 cell value / VBA formula

Rey99

New Member
Joined
Apr 13, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi all!

Here is my question, any help would be much appreciated!

I have 3 pivot tables on a sheet that is referring to the same data.

I'm entering the contract number I would like the results for in cell A2, for example WQ19. How can I have all the filters ''contract'' in each pivot table updated to this contract number or any contract number entered and show the results.

I have this formula that work for 1 pivot table but as soon as I add another pivot table on the same sheet, the formula is not working and I don't know how to fix it.

Here is what I have for 1 pivot table;

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$2" Then Exit Sub
Dim Sh As Worksheet, Pt As PivotTable
For Each Sh In Worksheets
For Each Pt In Sh.PivotTables
With Pt.PivotFields("contract")
.ClearAllFilters
.CurrentPage = Target.Value
End With
Next Pt
Next Sh
End Sub


Thank you ! :)
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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