VBA Multiple Slicers

Rik76

New Member
Joined
Feb 4, 2019
Messages
9
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
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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