Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
When Screenupdating = False is a lie
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
When Screenupdating = False is a lie
Forgot to mention Excel 2003
"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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
When Screenupdating = False is a lie
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
When Screenupdating = False is a lie
Seems like I remember something about screenupdating gets set back to true
after a macro. Might be something about a macro calling a macro. Could try to add screenupdating=false in the second macro. Jerry |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
When Screenupdating = False is a lie
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
When Screenupdating = False is a lie
Hi Dave, well thanks to that debugging procedure it showed that events, calc
and screen were all being reset on three different occasions, when I fooled around with the values of cells that also triggered events (don't know how excel didn't crash). All good now and running much faster because I have reset calc to false each time. Thanks very much for your help and tip. Regards, Brett (btw do you have any clues on the activeX question that I posted?. "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 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
When Screenupdating = False is a lie
Hi Jerry, good thought, but not the case. I think that only happens at the
end of all execution. I know that in many instances I only set it once for executing several macros. Certainly DisplayAlerts is reset at the end of EACH macro. The real answer can be seen in my last reply to Dave. Thanks for your reply. Brett "JerryH" wrote: Seems like I remember something about screenupdating gets set back to true after a macro. Might be something about a macro calling a macro. Could try to add screenupdating=false in the second macro. Jerry |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
When Screenupdating = False is a lie
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
screenupdating=false not working | Excel Programming | |||
ScreenUpdating = FALSE | Excel Programming | |||
How to set Application.ScreenUpdating = False for Gen use | Excel Discussion (Misc queries) | |||
What does ScreenUpdating = False do? | Excel Worksheet Functions | |||
Application.ScreenUpdating = False | Excel Programming |