Help with VBA to connect slicers with different data sources

anamnesis111

New Member
Joined
Apr 6, 2018
Messages
1
Hi, I have 4 data sources and 10 pivots so I created 4 slicers. To link the 4 slicers, I wrote this VBA but it is not working. Can someone please help?

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim sc1 As SlicerCache
Dim sc2 As SlicerCache
Dim sc3 As SlicerCache
Dim sc4 As SlicerCache
Dim SI1 As SlicerItem
Dim SI2 As SlicerItem
Dim SI3 As SlicerItem




Set sc1 = ThisWorkbook.SlicerCaches("Slicer_Community")
Set sc2 = ThisWorkbook.SlicerCaches("Slicer_Community1")
Set sc3 = ThisWorkbook.SlicerCaches("Slicer_Community2")
Set sc4 = ThisWorkbook.SlicerCaches("Slicer_Community3")


Application.ScreenUpdating = False
Application.EnableEvents = False


sc2.ClearManualFilter
sc3.ClearManualFilter
sc4.ClearManualFilter


For Each SI1 In sc1.SlicerItems
sc2.SlicerItems(SI1.Name).Selected = SI1.Selected
Next SI1


For Each SI2 In sc2.SlicerItems
sc3.SlicerItems(SI2.Name).Selected = SI2.Selected
Next SI2

For Each SI3 In sc3.SlicerItems
sc4.SlicerItems(SI3.Name).Selected = SI3.Selected
Next SI3


Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

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