Sync Slicers in Excel

Bram1212

New Member
Joined
Apr 12, 2018
Messages
36
Hi!

I tried to use the sync slicers guide (https://www.mrexcel.com/news/sync-slicers-in-excel/) but it's not working for me.

This is the code I have:
Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
    Dim sc1 As SlicerCache
    Dim sc2 As SlicerCache
    Dim SI1 As SlicerItem


    ' These names come from Slicer Settings dialog box
    Set sc1 = ThisWorkbook.SlicerCaches("Slicer_ISO_Year____Week____Day")
    Set sc2 = ThisWorkbook.SlicerCaches("Slicer_ISO_Year____Week____Day1")


    Application.ScreenUpdating = False
    Application.EnableEvents = False


    sc2.ClearManualFilter


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


    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub
The 2 slicers are on worksheet 1. The pivottables are on 6 other worksheets. So:
Worksheet 1: 2 slicers
Worksheet 2: 1 pivottable connected to slicer 1
Worksheet 3: 1 pivottable connected to slicer 1
Worksheet 4: 1 pivottable connected to slicer 1
Worksheet 5: 1 pivottable connected to slicer 2
Worksheet 6: 1 pivottable connected to slicer 2
Worksheet 7: 1 pivottable connected to slicer 2

Is that something I need to specify in the code?

Thanks!
 
Last edited by a moderator:
Unfortunately not. I have uploaded it onto a different forum. You should be able to acces it without an account.
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Yes, that would have sped things up. ;)

You've put the code in the Combined data sheet, which doesn't have a pivot table on it.
 
Upvote 0
Finally got this to work. Please note that if the items in the slicers are not exactly the same, the code will produce an error. I had one item missing on the secondary slicer. Added a line with 0s for data, and it works fine.

The annoying bit is that I can't get Application.Enable Events to stay set to true. :( Any thoughts would be appreciated.
 
Upvote 0
Are you using the code exactly as posted here? It sounds like your code is disabling events and not re-enabling them.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
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