View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
onedaywhen onedaywhen is offline
external usenet poster
 
Posts: 459
Default ScreenUpdating automatically resets to True

Can anyone shed any light on why my help file shows contradictory
information about Application.ScreenUpdating to Bob Phillips'?

Bob's says ScreenUpdating is local to the procedure it is used in and
its value reverts to True when the local procedure ends. However, mine
(Excel 2002 and Excel 2003 beta) says *I* must revert the value to
True thereby implying its scope is global, as I would expect from an
Application-level property.

Can anyone suggest which is right?

Many thanks.

(onedaywhen) wrote in message . com...
Bob,
Thanks for replying.

It's nothing to do with activating a worksheet, it is simply local to the
procedure it is set in. When that procedure ends, it reverts back to True,
as stated in the online help.


That's not what it says in the online (F1) help for the version of
Excel I'm using, being Excel 2003 beta. Rather than saying it reverts
to True, it actually tells *me* to change it back to True, quote:

"Remember to set the ScreenUpdating property back to True
when your macro ends."

This confirms it isn't local to the procedure it is set in otherwise
they'd be no need to set the ScreenUpdating property back to True, I
could just let it go out of scope. Or am I missing something (a help
file, the point, etc)?

Thanks again.

"Bob Phillips" wrote in message ...
It's nothing to do with activating a worksheet, it is simply local to the
procedure it is set in. When that procedure ends, it reverts back to True,
as stated in the online help.

--

HTH

Bob Phillips

"onedaywhen" wrote in message
m...
The ScreenUpdating property seems to implicitly/automatically be set
to true when a worksheet is activated. Is this expected behaviour? I
would expect the value of ScreenUpdating to persist until *I* change
it.

Here's some code that demonstrates what I mean (paste it into all
worksheet code modules):

Private Sub Worksheet_Deactivate()
With Application
.ScreenUpdating = False
.Cursor = xlWait
End With
End Sub

Private Sub Worksheet_Activate()
With Application
Stop ' ScreenUpdating should be False
.ScreenUpdating = True
.Cursor = xlDefault
End With
End Sub

When the Stop is encountered ScreenUpdating should be false; it was
set to false when the cursor was changed to the hourglass. However, at
the Stop I have the hourglass cursor but ScreenUpdating is now true.

Sure, I can turn it off again but I get a flicker each time I toggle
this property. And because in reality I'm using the
_Activate/_Deactivate events to run initialize/cleanup code, possibly
reactivating the worksheets in the process, this is adding up to a lot
of flickering ... which is of course what I was trying to eliminate by
turning ScreenUpdating off!

Is this something I've got to learn to live with or is it likely I'm
doing something wrong?