Screen flickers while macro is running

D

Derek Dowle

Usually the code

Application.ScreenUpdating = False
and
Application.ScreenUpdating = True

switches off and then switches on screen updating successfully without any
problems.

'Private Sub Worksheet_Activate()' of a worksheet calls a macro in the
Modules.

This macro jumps between worksheets to gather information. The
ScreenUpdating keeps the screen focused on the activated worksheet whilst the
macro is running. Whilst the macros is running the active screen flickers.
The macro does everything else asked of it.

What is the code please to stop the screen from flickering.

Many thanks
 
P

Patrick Molloy

your code is probably activating sheets ....without seeing the code, this is
a guess . however, there's usually no need to activate sheets when updating
data

so
worksheets("Sheet1").Activate
range("A1").Copy
worksheets("Sheet2").Activate
range("A1").Pastespecial xlallvalues

can be replaced by

worksheets("Sheet1").range("A1").Copy
worksheets("Sheet2").range("A1").Pastespecial xlallvalues
 
J

Jacob Skaria

I understand the macro is called from the activate event...try....

Application.EnableEvents = False
Application.ScreenUpdating = False
'call macro
Application.EnableEvents = True
Application.ScreenUpdating = True
 
D

Derek Dowle

Patrick

In a roundabout way you have provided the answer, thank you. I no longer
get the flickering. It was not the answer I was expecting as I recollect
having seen in the discussion group some years ago another way around the
problem by putting a statement at the beginning and end of the code in a
similar fashion to the 'screenupdating'. I should have made a note of it.

My code was not as straight forward copy and paste. One sheet contained
data and the macro manipulates the data and then uses it to populate cell
comments on another sheet. When the focus is moved to this other sheet the
comments automatically get updated via the Worksheet_Activate() sub.

Gathering the data by looking at the data sheet rather than going to it
solve the problem.
 
D

Derek Dowle

Jacob

As you will have seen by my reply to Patrick's helpful response I was
expecting something different. I will make a proper record of your answer
on this occaision.

Thank you
 

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

Top