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:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Welcome to the forum.

What exactly does "doesn't work" mean?

Did you put the code in the worksheet code module of a worksheet with a pivot table on it?
 
Upvote 0
He Rory,

Thanks!

No the code is on a worksheet without pivottables. The macro does not give an error but does not sync the slicers either.
 
Upvote 0
If there isn't a pivot table on that worksheet, the code won't be triggered. It needs to be in a sheet with a pivot table.
 
Upvote 0
There just needs to be at least one of them on the sheet with the code.
 
Upvote 0
Is the code behind that same worksheet?
 
Last edited:
Upvote 0
Add this:

Code:
Msgbox "Triggered"

before the Set sc1 = ... line and then change a slicer. Do you see a message?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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