Question on application.screenupdating

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Could someone tell what's the best practise one using screenupdating with
following situation:

One sub contains call to 4 to 5 others sub, of this 4 to 5, only 1 don't
write to sheet. Should I placed screenupdating to each sub or to the master
sub??

Right now, I coded screenupdating under the master sub, but I notice that
when I execute it, the screen flicker. SHould this happen??

Thanks
Regards
 
Hi Augusus,
Could someone tell what's the best practise one using screenupdating with
following situation:

One sub contains call to 4 to 5 others sub, of this 4 to 5, only 1 don't
write to sheet. Should I placed screenupdating to each sub or to the
master
sub??

Right now, I coded screenupdating under the master sub, but I notice that
when I execute it, the screen flicker. SHould this happen??


If ScreenUpdating is set to False in the first sub, this setting should
persist through the chained calls.

As a test, I ran Sub Main which calls a second sub which, in turn, calls a
third sub. To check the flicker issue, I included sheet selection and
multiple cell selections (1000) in each sub.

ScreenUpdating remained off through the calls and flicker did not appear
to pose a problem..

Sub Main()
Dim i As Long
With Application
.ScreenUpdating = False

Sheets(2).Select
For i = 1 To 1000
Cells(i, 1).Select
Next
One
MsgBox "On return to Main, ScreenUpdating = " & .ScreenUpdating
.ScreenUpdating = True
End With
End Sub

Sub One()
Dim i As Long

With Application
Sheets(1).Select
For i = 1 To 1000
Cells(i, 1).Select
Next
MsgBox "ScreenUpdating in One = " & .ScreenUpdating
Two
End With
End Sub

Sub Two()
Dim i As Long

With Application
Sheets(3).Select
For i = 1 To 1000
Cells(i, 1).Select
Next
MsgBox "ScreenUpdating in Two = " & .ScreenUpdating
End With
End Sub

Perhaps something in your code is restoring ScreenUpdating.
 
There are somethings that turn on screenupdating.

If you pepper your code with:

Debug.print "step 1: " & application.screenupdating

then later...

Debug.print "step 2: " & application.screenupdating

(and a few(?) more!)

You should be able to find the line(s) that turn it back on. Then you can add
one more "application.screenupdating = false" right after that troublesome line
of code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top