Good Morning,
I have a question about how I can optimize a macro.
The macro connects three slicers. It only takes a very long time, more than two minutes before the marcro is ready.
Do you have some ideas how I can speed this up?
Macro:
I have a question about how I can optimize a macro.
The macro connects three slicers. It only takes a very long time, more than two minutes before the marcro is ready.
Do you have some ideas how I can speed this up?
Macro:
Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim sc1 As SlicerCache
Dim sc2 As SlicerCache
Dim sc3 As SlicerCache
Dim SI1 As SlicerItem
Dim SI2 As SlicerItem
' These names come from Slicer Settings dialog box
Set sc1 = ThisWorkbook.SlicerCaches("Slicer_Week3")
Set sc2 = ThisWorkbook.SlicerCaches("Slicer_Week2")
Set sc3 = ThisWorkbook.SlicerCaches("Slicer_Week")
Application.ScreenUpdating = False
Application.EnableEvents = False
sc2.ClearManualFilter
sc3.ClearManualFilter
For Each SI1 In sc1.SlicerItems
sc2.SlicerItems(SI1.Name).Selected = SI1.Selected
Next SI1
For Each SI2 In sc1.SlicerItems
sc3.SlicerItems(SI2.Name).Selected = SI2.Selected
Next SI2
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: