daviserika
New Member
- Joined
- Jan 25, 2019
- Messages
- 1
Caught the video on youttube which led me to this link: (https://www.mrexcel.com/news/sync-slicers-in-excel/). I pasted the code and it's crashing on me when it gets to the For Each line of the code, I get a runtime error '1004' application defined or object-defined error.
My code is barely modified from the example. What step did I miss?
I checked the slicer names and the ClearManualFilter is working so it's not that.
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim sc1 As SlicerCache
Dim sc2 As SlicerCache
Dim SI1 As SlicerItem
Dim fred As SlicerItems
' These names come from Slicer Settings dialog box
Set sc1 = ThisWorkbook.SlicerCaches("Slicer_DMSL3")
Set sc2 = ThisWorkbook.SlicerCaches("Slicer_DMSL6")
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
My code is barely modified from the example. What step did I miss?
I checked the slicer names and the ClearManualFilter is working so it's not that.
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim sc1 As SlicerCache
Dim sc2 As SlicerCache
Dim SI1 As SlicerItem
Dim fred As SlicerItems
' These names come from Slicer Settings dialog box
Set sc1 = ThisWorkbook.SlicerCaches("Slicer_DMSL3")
Set sc2 = ThisWorkbook.SlicerCaches("Slicer_DMSL6")
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