Using Screen Updating

julhs

Active Member
Joined
Dec 3, 2018
Messages
407
Office Version
  1. 2010
Platform
  1. Windows
Need some clarification on this.

I have a Main Sub that has Screen Updating False/True at the beginning and end of it.
The Main Sub, part way through calls a Secondary Sub that ALSO has Screen Updating False/True.

The question is; when the Secondary Sub has run and it goes back to the Main Sub, is the Main Sub Screen Updating now set to “=True” ( as set by the Secondary Sub) or does it default back to the Main Sub’s setting of “= False”.

To explain it another way.
Main Sub - Screen Updating = False
Call Secondary Sub - Screen Updating = False
Run Secondary Sub
Secondary Sub - Screen Updating = True
Return to Main Sub
Now is the status of Screen Updating in the Main Sub “True” or “False”?

I did add an extra Screen Updating “= False” to the Main Sub after the Secondary had run but still getting more screen flicker than I would like

This is not a trick question!!!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Since ScreenUpdating is an Application Property it will be equal to True when returning to the Main Sub.
 
Upvote 0
So me using Screen Updating “= False” in the Main Sub immediately AFTER calling the Secondary Sub would be correct?

If that is the case; I will have to either live with the screen flicker or come up with a different sequence.
Thanks
Julhs
 
Upvote 0
VBA Code:
Main Sub()
Application.ScreenUpdating = False
' Some Code
Application.ScreenUpdating = True
End Sub
Secondary Sub()
Application.ScreenUpdating = True
' Some Code
Application.ScreenUpdating = False
End Sub
If the Secondary Sub() ends before the End Sub line then you will have to add the line Application.ScreenUpdating = False before that point as well. Screen will flicker if any changes are made during Secondary Sub()
 
Upvote 0
If you are calling the second sub from the Main sub, there is no need to have the Application.ScreenUpdating settings in the second sub.

In other words when you call the second sub, Application.ScreenUpdating is already set to false from the Main sub, there is no need to set it to false again in the second sub.

Leave the Application.ScreenUpdating settings completely out of the second sub, unless there is a certain section of the second sub that you want to enable the Application.ScreenUpdating setting.
 
Upvote 0
My apologise, seems I uploaded tread without code tags
VBA Code:
Public Sub Reset_All_Shapes()
Dim sht As Worksheet
Dim rng As Range
Dim FrwD As Long
'---------------------------------------------------------
'NOTE;
'RR = Rounded Rectangle shape
'SC = Straight Connector shape
'SAC = Straight Arrow Connector shape
'Rect = Rectangle shape
'---------------------------------------------------------
Set sht = ThisWorkbook.ActiveSheet
Set rng = Range("AK:AK").Find(What:="Paid To", LookIn:=xlValues, LookAt:=xlWhole)
FrwD = rng.Row
Application.ScreenUpdating = False
Application.EnableEvents = False
'----------------------------------------------------------
'### Get Used range area on the sheet
'Pink fill
Range("AZ" & FrwD + 94 & ":CC" & FrwD + 99).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 14281213
.TintAndShade = 0
.PatternTintAndShade = 0
End With

ActiveSheet.Shapes("RR 102").Fill.ForeColor.RGB = RGB(255, 0, 0)
ActiveSheet.Shapes("SAC 103").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 17").Fill.ForeColor.RGB = RGB(161, 161, 161)
'----------------------------------------------------
'### Select Sub To Run area on the sheet
'Pink fill
Range("AZ" & FrwD + 65 & ":CC" & FrwD + 92).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 14281213
.TintAndShade = 0
.PatternTintAndShade = 0
End With

ActiveSheet.Shapes("RR 170").Fill.ForeColor.RGB = RGB(255, 0, 0)
ActiveSheet.Shapes("SAC 171").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 169").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 172").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 168").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 178").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 173").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 176").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 174").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 177").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 175").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SC 179").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 180").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 181").line.ForeColor.RGB = RGB(217, 217, 217)
'Coming down Left side
ActiveSheet.Shapes("SC 119").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 120").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 117").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SC 129").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 125").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 122").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 115").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 123").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 124").Fill.ForeColor.RGB = RGB(161, 161, 161)

'SC179, SC180, SC181 already greyed
ActiveSheet.Shapes("SC 114").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 121").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 118").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SC 128").line.ForeColor.RGB = RGB(217, 217, 217)

'SC115, SAC123, RR124 already greyed
ActiveSheet.Shapes("SC 126").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 127").line.ForeColor.RGB = RGB(217, 217, 217)

ActiveSheet.Shapes("RR 76").Visible = False
ActiveSheet.Shapes("RR 160").Visible = False
ActiveSheet.Shapes("RR 162").Visible = False
'------------------------------------------------------
'### Validation List area on the sheet
'Pink fill
Range("AZ" & FrwD + 2 & ":CC" & FrwD + 63).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 14281213
.TintAndShade = 0
.PatternTintAndShade = 0
End With

ActiveSheet.Shapes("RR 194").Fill.ForeColor.RGB = RGB(250, 0, 0)
ActiveSheet.Shapes("SAC 206").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 133").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 215").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 212").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 210").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 130").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 112").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 131").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 111").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 132").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 107").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 129").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 108").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 109").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 134").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 110").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SC 153").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 135").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 165").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 219").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 217").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 223").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 183").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 106").line.ForeColor.RGB = RGB(217, 217, 217)

'### This section is coming down the LEFT side from SC106
ActiveSheet.Shapes("SC 104").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 167").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 114").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 136").Fill.ForeColor.RGB = RGB(161, 161, 161)

ActiveSheet.Shapes("SAC 142").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 145").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 139").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 150").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 138").Fill.ForeColor.RGB = RGB(161, 161, 161)

ActiveSheet.Shapes("SC 149").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 198").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 148").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 146").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 152").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 144").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 154").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 143").Fill.ForeColor.RGB = RGB(161, 161, 161)

ActiveSheet.Shapes("SC 199").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 141").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 140").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 151").line.ForeColor.RGB = RGB(217, 217, 217)
' RR144, SAC154, RR143 already greyed

'### This section is coming down the RIGHT side from SC106
' SAC183 already greyed
' SC106 already greyed
ActiveSheet.Shapes("SC 189").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 105").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 137").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 100").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 157").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 158").line.ForeColor.RGB = RGB(217, 217, 217)

'## RR139, SAC150, RR138 already greyed
ActiveSheet.Shapes("SC 162").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SC 191").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 161").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 159").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 164").line.ForeColor.RGB = RGB(217, 217, 217)
'## RR144, SAC154, RR143 already greyed

ActiveSheet.Shapes("SC 193").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("SAC 156").line.ForeColor.RGB = RGB(217, 217, 217)
ActiveSheet.Shapes("RR 155").Fill.ForeColor.RGB = RGB(161, 161, 161)
ActiveSheet.Shapes("SAC 163").line.ForeColor.RGB = RGB(217, 217, 217)
'## RR144, SAC154, RR143 already greyed

ActiveSheet.Shapes("RR 76").Visible = False
ActiveSheet.Shapes("RR 160").Visible = False
ActiveSheet.Shapes("RR 162").Visible = False
ActiveSheet.Shapes("RR 179").Visible = False
ActiveSheet.Shapes("RR 180").Visible = False
ActiveSheet.Shapes("RR 185").Visible = False
ActiveSheet.Shapes("RR 190").Visible = False
ActiveSheet.Shapes("RR 195").Visible = False
ActiveSheet.Shapes("RR 200").Visible = False
ActiveSheet.Shapes("RR 205").Visible = False
ActiveSheet.Shapes("RR 210").Visible = False

ActiveSheet.Shapes("Rect 1").Visible = True
ActiveSheet.Shapes("Rect 2").Visible = True
ActiveSheet.Shapes("Rect 3").Visible = True
ActiveSheet.Shapes("Rect 4").Visible = True
ActiveSheet.Shapes("Rect 5").Visible = True
ActiveSheet.Shapes("Rect 6").Visible = True
ActiveSheet.Shapes("Rect 7").Visible = True
ActiveSheet.Shapes("Rect 8").Visible = True

Range("AJ" & FrwD - 9).Select
Application.Goto Selection, Scroll:=True
Range("AT" & FrwD).Select

Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub
 
Upvote 0
Your Application.ScreenUpdating methods are properly placed. I don't think that you will be able to avoid the flickering unless you hide the Application while the Sub runs.
 
Upvote 0
Well I am a bit puzzled!!
When I can back to this today the screen flicker had stopped.
I don’t recall changing anything late last night, but just may have done.
Maybe problem was cured by the closing and restarting of Excel.
Who knows, I’m just glad it’s no longer happening.

Thank you SkkyBot and JonnyL for your input, much appreciated.
Julhs
 
Upvote 0
If you are calling the second sub from the Main sub, there is no need to have the Application.ScreenUpdating settings in the second sub.

In other words when you call the second sub, Application.ScreenUpdating is already set to false from the Main sub, there is no need to set it to false again in the second sub.

Leave the Application.ScreenUpdating settings completely out of the second sub, unless there is a certain section of the second sub that you want to enable the Application.ScreenUpdating setting.
Just as a by the way I need False/True in the second sub because it is also used as a stand alone assigned to a button
 
Upvote 0
What you can do is either leave out resetting it to True (which should happen by default when your code finishes anyway), or store the initial value of screenupdating (and enableevents) and reset to that value at the end.
 
Upvote 0

Forum statistics

Threads
1,215,129
Messages
6,123,212
Members
449,090
Latest member
bes000

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