Screen flashing during macro execution: Interesting observation

  • Thread starter Thread starter jasonsweeney
  • Start date Start date
J

jasonsweeney

I ran a macro, from a useform, that inserted about 100 comments int
cells on 10 different worksheets.

As many have talked about in this forum, the screen "flashed" durig
execution of the macro, despite that in the code was written:

_________
Application.ScreenUpdating = False
' Sheet1 code
' Sheet2 code
' etc.
Application.Screenupdating = True
__________

For giggles, I changed the code to:

_________
Application.ScreenUpdating = False
' Sheet1 code
Application.Screenupdating = True
'
Application.ScreenUpdating = False
' Sheet2code
Application.Screenupdating = True
'
Application.ScreenUpdating = False
' etx.
Application.Screenupdating = True
__________

Of course, this did not solve the problem, as many have commented.
Then I tried this:

Application.ScreenUpdating = False
' Sheet1 code
Application.ScreenUpdating = False
' Sheet2code
Application.ScreenUpdating = False
' Sheet3.code
Application.Screenupdating = False
' Etc.
Application.Screenupdating = False

And,.........it Worked! I only got one screen "flash" by doing it thi
way. The macro still wasn't as quick as one would desire, but it di
solve the flashing issue. Just wondering if anybody else ha
experienced success with this strategy.

Jason Sweene
 
There are somethings that turn screenupdating to true. I don't recall functions
that do this when dealing with comments, but you could try to isolate it by
peppering your code with debug statements like:

debug.print "made it to step 1: " & application.screenupdating

Then look a the debug window to see where screenupdating changed to true.

Then when you find it, you can just turn it off right after that statement.
 
Are you activating the other sheets ? and if so, do you have any code in the
Activate/Deactivate events of those sheets ?
 
Back
Top