Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Screen Updating

Is there a way to prevent screenupdating when calling a macro from
inside another macro? In this example
when running macro 1, macro 2 is called and one of the lines says
screenupdating=true and would then update the screen before macro 3
runs.

( I am actually running into this because im using ActiveX boxes
with cmb_change() ) the only thing i can think of is to set a bunch of
variables as boolean and use if then statements before the
application.screenupdating=true command. Unless there is a way to set
a variable for the original caller sub?

Thanks



sub macro1()
application.screenupdating=false
Call macro2
Call macro3 ' Not shown
application.screenupdating=true
end sub

sub macro2()
application.screenupdating=false
'do some code
application.screenupdating =true
End sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Screen Updating

No not as written (if I follow). Indeed it's well worth ensuring that
ScreenUpdating is only reset once within a multiple series of routines, or
you'll get a flicker each time. Try and do something like this -

Sub main()
Application.screenupdating = false
call Macro1
Call Macro2
Application.screenupdating = True
end sub

and remove 'application.screenupdating=true' from both macro1 & 2

If for other reasons it's not viable to remove the reset in each macro, a
lazy alternative alternative (frowned on by some) might be something like
this

Public gbDontUpdate as Boolean ' top of a normal module

Sub main()
' best to ensure code returns even if errors elsewhere
on error goto errH '
Application.screenupdating = false
gbNoScrUpdating = True
call Macro1
Call Macro2
errExit:
Application.screenupdating = True
gbNoScrUpdating = True
end sub

In both Macro1 & macro2 -

If Not gbNoScrUpdating Then
Application.screenupdating = True
End if

Regards,
Peter T


wrote in message
...
Is there a way to prevent screenupdating when calling a macro from
inside another macro? In this example
when running macro 1, macro 2 is called and one of the lines says
screenupdating=true and would then update the screen before macro 3
runs.

( I am actually running into this because im using ActiveX boxes
with cmb_change() ) the only thing i can think of is to set a bunch of
variables as boolean and use if then statements before the
application.screenupdating=true command. Unless there is a way to set
a variable for the original caller sub?

Thanks



sub macro1()
application.screenupdating=false
Call macro2
Call macro3 ' Not shown
application.screenupdating=true
end sub

sub macro2()
application.screenupdating=false
'do some code
application.screenupdating =true
End sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Screen Updating

Ya, doing your first example is not viable because sometimes the
macros get run alone. I found a similar solution after some digging
(which is a little more useful) at http://www.excelguru.ca/node/54

Thanks for the help!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen Updating Raman325[_9_] Excel Programming 2 June 30th 05 08:45 PM
Screen Updating Michael Excel Worksheet Functions 3 March 14th 05 09:53 PM
Screen Updating KG[_4_] Excel Programming 0 January 16th 05 05:09 PM
Screen updating Keith[_11_] Excel Programming 2 June 2nd 04 01:10 PM
Screen Updating Chilidog1000[_2_] Excel Programming 1 January 6th 04 08:18 PM


All times are GMT +1. The time now is 04:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"