whitehawk81
Board Regular
- Joined
- Sep 4, 2016
- Messages
- 66
Hi,
I got an annoying issue with Application.ScreenUpdating. It worked fine until I added a secondary subroutine into the code. I tried to look for a solution and already attempted to fix the issue by calling the following subs at the beginning and at the end of the primary and secondary subs as well:
This is the original code, that was working fine with Application.ScreenUpdating:
And currently it looks like this:
Is there a way to fix the application.screenupdating behaviour?
I got an annoying issue with Application.ScreenUpdating. It worked fine until I added a secondary subroutine into the code. I tried to look for a solution and already attempted to fix the issue by calling the following subs at the beginning and at the end of the primary and secondary subs as well:
Code:
Public Sub TU_Start() Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
End Sub
Public Sub TU_End()
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
This is the original code, that was working fine with Application.ScreenUpdating:
Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)Dim sc1 As SlicerCache, sc2 As SlicerCache, sc3 As SlicerCache, sc4 As SlicerCache, sc5 As SlicerCache, sc6 As SlicerCache, sc7 As SlicerCache, sc8 As SlicerCache, sc9 As SlicerCache
Dim si1 As SlicerItem, si3 As SlicerItem, si5 As SlicerItem, si7 As SlicerItem
Set sc1 = ThisWorkbook.SlicerCaches("Slicer_Jahr")
Set sc2 = ThisWorkbook.SlicerCaches("Slicer_Jahr1")
Set sc3 = ThisWorkbook.SlicerCaches("Slicer_SolName")
Set sc4 = ThisWorkbook.SlicerCaches("Slicer_SolName1")
Set sc5 = ThisWorkbook.SlicerCaches("Slicer_Quarter")
Set sc6 = ThisWorkbook.SlicerCaches("Slicer_Quarter1")
Set sc7 = ThisWorkbook.SlicerCaches("Slicer_Monat")
Set sc8 = ThisWorkbook.SlicerCaches("Slicer_Monat1")
Set sc9 = ThisWorkbook.SlicerCaches("Slicer_Solution")
Application.ScreenUpdating = False
Application.EnableEvents = False
sc2.ClearManualFilter
sc4.ClearManualFilter
sc6.ClearManualFilter
sc8.ClearManualFilter
sc9.ClearManualFilter
On Error Resume Next
For Each si1 In sc1.SlicerItems
sc2.VisibleSlicerItems(si1.Name).Selected = si1.Selected
Next si1
For Each si3 In sc3.SlicerItems
sc4.VisibleSlicerItems(si3.Name).Selected = si3.Selected
sc9.VisibleSlicerItems(si3.Name).Selected = si3.Selected
Next si3
For Each si5 In sc5.SlicerItems
sc6.VisibleSlicerItems(si5.Name).Selected = si5.Selected
Next si5
For Each si7 In sc7.SlicerItems
sc8.VisibleSlicerItems(si7.Name).Selected = si7.Selected
Next si7
On Error GoTo 0
clean_up:
Application.EnableEvents = True
Application.ScreenUpdating = True
'Exit Sub
err_handle:
MsgBox Err.Description
Resume clean_up
End Sub
And currently it looks like this:
Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)Dim sc1 As SlicerCache, sc2 As SlicerCache, sc3 As SlicerCache, sc4 As SlicerCache, sc5 As SlicerCache, sc6 As SlicerCache, sc7 As SlicerCache, sc8 As SlicerCache, sc9 As SlicerCache
Dim si1 As SlicerItem, si3 As SlicerItem, si5 As SlicerItem, si7 As SlicerItem
Set sc1 = ThisWorkbook.SlicerCaches("Slicer_Jahr")
Set sc2 = ThisWorkbook.SlicerCaches("Slicer_Jahr1")
Set sc3 = ThisWorkbook.SlicerCaches("Slicer_SolName")
Set sc4 = ThisWorkbook.SlicerCaches("Slicer_SolName1")
Set sc5 = ThisWorkbook.SlicerCaches("Slicer_Quarter")
Set sc6 = ThisWorkbook.SlicerCaches("Slicer_Quarter1")
Set sc7 = ThisWorkbook.SlicerCaches("Slicer_Monat")
Set sc8 = ThisWorkbook.SlicerCaches("Slicer_Monat1")
Set sc9 = ThisWorkbook.SlicerCaches("Slicer_Solution")
Call TU_Start
sc2.ClearManualFilter
sc4.ClearManualFilter
sc6.ClearManualFilter
sc8.ClearManualFilter
sc9.ClearManualFilter
On Error Resume Next
For Each si1 In sc1.SlicerItems
sc2.VisibleSlicerItems(si1.Name).Selected = si1.Selected
Next si1
For Each si3 In sc3.SlicerItems
sc4.VisibleSlicerItems(si3.Name).Selected = si3.Selected
sc9.VisibleSlicerItems(si3.Name).Selected = si3.Selected
Next si3
For Each si5 In sc5.SlicerItems
sc6.VisibleSlicerItems(si5.Name).Selected = si5.Selected
Next si5
For Each si7 In sc7.SlicerItems
sc8.VisibleSlicerItems(si7.Name).Selected = si7.Selected
Next si7
On Error GoTo 0
Call Filter_Columns("solH", "Dashboard", "Pivot", "SolPT", "Solution")
Call TU_End
End Sub
Is there a way to fix the application.screenupdating behaviour?