Re: When Screenupdating = False is a lie

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



If (and it's a big if!) you don't want those events to fire, you can use:

application.screenupdating = false
'a bunch of code here

application.enableevents = false
activesheet.range("a1").value = "hi" 'some event causing code
application.enableevents = true

'a bunch of code
application.screenupdating = true

End sub


I'd recommend that you turn off the events for as little time as you can. And
turn it on right after you're done with that line.

Brettjg wrote:

That was a great help Dave, TVM. Also a much better way to debug because it
keeps a record of things (never used the immediate window before). Apparently
when I changed the value of one particular cell updating switched back t true
- may have been the result of a change event, except that events are
definitely off otherwise excel crashes. It can remain a mystery, just as long
as it works! Thanks again.

"Dave Peterson" wrote:

I've seen calls to procedures in the analysis tookpak toggle that screenupdating
procedure. But that doesn't seem to fit your situation.

Instead of using msgboxes, you may want to use debug.print. You'll see the
"report" in the immediate window in the VBE.

I'd pepper the code with lines like:

application.screenupdating = false
Debug.print "Before Step 1: " & application.screenupdating
'do a few lines of code
Debug.print "Before step 2: " & application.screenupdating
'a few more lines


Then you can run the procedure and see where true is returned. Then you can be
more thorough. Add a bunch of those debug.print lines between each line of the
portion of code that saw that setting get set to true.

=====
It could be that you're calling another procedure that turns it off, then turns
it back on when it's done????

Brettjg wrote:

Hi there

I'm running a macro that is called from another macro ans updating has been
set to false. However, under some circumstances I can still see the screen
being populated, and of course the macro runs very slowly indeed.

For debugging I included the following lines:

Application.ScreenUpdating = True
If Application.ScreenUpdating = True Then: MsgBox "TRUE"
Application.ScreenUpdating = False
If Application.ScreenUpdating = False Then: MsgBox "FALSE"
code immediately after this populates the page (which is what I can see
happening)

There NO OTHER REFERENCES to updating, except at the end of the caller.

Of course both msgboxes come up (as I would expect, but I can still see the
population happening, so obviously updating is not false at all
or................there's something else going on that I don't understand.
Does anyone have an idea here please? Regards, Brett

--

Dave Peterson


--

Dave Peterson
.



Relevant Pages

  • Re: Opening TXT too slow
    ... dim wkbk as workbook ... '''another bunch of code ... Dave Peterson ...
    (microsoft.public.excel)
  • Re: simple question for newbie
    ... with updating a bunch of DNS zone files of them. ... All of the files have the SNs in this format: ...
    (comp.os.linux.misc)
  • Re: Comprehensive and reliable library?
    ... Delphi Companion DVD comes to mind... ... I'm finding a bunch of my old favorite components and ... component libraries need updating. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: New Berkeley Cam
    ... that periodocally pan and zoom and take a ... bunch of photos, updating every minute? ...
    (rec.windsurfing)
  • Re: Title bar not up-dating after running the macro below
    ... The existing file won't be changed, but the workbook you're updating will now be the new name. ... See VBA's help for all the parms you need to supply. ... Dave Peterson ...
    (microsoft.public.excel.programming)