Hi,
I have used the following code to link multiple slicers, however the process is very slow. This was my first attempt at using VBA, so wondered whether anyone had any tips or ideas on how I could speed up the process. Any hep appreciated!
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 sc5 As SlicerCache
Dim Sc6 As SlicerCache
Dim si1 As SlicerItem
Set sc1 = ThisWorkbook.SlicerCaches("Slicer_Name15")
Set sc2 = ThisWorkbook.SlicerCaches("Slicer_Name1")
Set sc3 = ThisWorkbook.SlicerCaches("Slicer_Name11")
Set sc4 = ThisWorkbook.SlicerCaches("Slicer_Name12")
Set sc5 = ThisWorkbook.SlicerCaches("Slicer_Name13")
Set Sc6 = ThisWorkbook.SlicerCaches("Slicer_Name14")
Application.EnableEvents = False
sc2.ClearManualFilter
sc3.ClearManualFilter
sc4.ClearManualFilter
sc5.ClearManualFilter
sc6.ClearManualFilter
On Error Resume Next
For Each si1 In sc1.SlicerItems
sc2.SlicerItems(si1.Name).Selected = si1.Selected
sc3.SlicerItems(si1.Name).Selected = si1.Selected
sc4.SlicerItems(si1.Name).Selected = si1.Selected
sc5.SlicerItems(si1.Name).Selected = si1.Selected
sc6.SlicerItems(si1.Name).Selected = si1.Selected
Next
On Error GoTo 0
MsgBox "Update Complete"
clean_up:
Application.EnableEvents = True
Application.ScreenUpdating = False
Exit Sub
err_handle:
MsgBox Err.Description
Resume clean_up
End Sub
I have used the following code to link multiple slicers, however the process is very slow. This was my first attempt at using VBA, so wondered whether anyone had any tips or ideas on how I could speed up the process. Any hep appreciated!
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 sc5 As SlicerCache
Dim Sc6 As SlicerCache
Dim si1 As SlicerItem
Set sc1 = ThisWorkbook.SlicerCaches("Slicer_Name15")
Set sc2 = ThisWorkbook.SlicerCaches("Slicer_Name1")
Set sc3 = ThisWorkbook.SlicerCaches("Slicer_Name11")
Set sc4 = ThisWorkbook.SlicerCaches("Slicer_Name12")
Set sc5 = ThisWorkbook.SlicerCaches("Slicer_Name13")
Set Sc6 = ThisWorkbook.SlicerCaches("Slicer_Name14")
Application.EnableEvents = False
sc2.ClearManualFilter
sc3.ClearManualFilter
sc4.ClearManualFilter
sc5.ClearManualFilter
sc6.ClearManualFilter
On Error Resume Next
For Each si1 In sc1.SlicerItems
sc2.SlicerItems(si1.Name).Selected = si1.Selected
sc3.SlicerItems(si1.Name).Selected = si1.Selected
sc4.SlicerItems(si1.Name).Selected = si1.Selected
sc5.SlicerItems(si1.Name).Selected = si1.Selected
sc6.SlicerItems(si1.Name).Selected = si1.Selected
Next
On Error GoTo 0
MsgBox "Update Complete"
clean_up:
Application.EnableEvents = True
Application.ScreenUpdating = False
Exit Sub
err_handle:
MsgBox Err.Description
Resume clean_up
End Sub