How to use VBA to update pivot table data source while still able to connect back to slicers?

YYF

New Member
Joined
Feb 9, 2023
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hi all,

Really need help since I can't solve it by myself :( I am not familiar with VBA and most of time I just try and error or search how other people write the code.. but i am stuck here.

I have 4 pivot tables (ABCD) in the same sheet and connect to 2 different data sources.
There are 4 slicers, and 2 slicers connect to 2 pivot tables (ie., A & B), and another 2 slicers connect to pivot tables C & D.

I've completed the code to disconnect slicers and still allow the pivot table to reconnect back in later stage (thanks for previous post back to 2012!). Now I need to change the pivot table source data, refresh, and reconnect to respective slicers, and this is the part I failed.

The code I can write is very stupid >"< and after change data source, it removes one of pivot table from the slicer (each slicer has the same issue) hence even after changing the data source, I can't link them back anymore.

Here is the code I have -

The disconnect from slicer is from another post and it works perfectly
1675936273640.png


But I don't know how to update different pivot tables in the same sheet with different sources in the same workbook so I just write it individually
And after ran this part, pivot table "OTB1" is gone in slicers
1675936400916.png


Many thanks for your help!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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