optimize Macro

Falkie

New Member
Joined
Mar 6, 2018
Messages
5
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:

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:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
may be try this , add to begin of your code
application.calculation = xlmanual
 
Upvote 0
and at the end make it automatic - CalculationAutomatic
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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