Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Application.ScreenUpdating MsgBox

I have a master Sub which calls in Sub routines in its body.
I want to be able to switch Screen.Updating on or off for ALL the main sub
and those subs referred to in it, but only answer the MsgBox once at the
beginning of the Sub.
How can I get the Answer to apply to all Subs?
Thanks in advance for your help.
Here is my code:
Sub Optimise()
Ans = MsgBox("ScreenUpdating?", vbYesNo)
Select Case Ans
Case vbYes
Application.ScreenUpdating = True
Case vbNo = False
Application.ScreenUpdating = False
End Select
If (condition) Then
MySub1
ElseIf (condition) Then
MySub2
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Application.ScreenUpdating MsgBox

Once turned off the screen will not update until you turn it back on. A
common mistake is to turn it off at the beginning of every sub and back on at
the end of each sub. This will cause the screen to flash when one sub calls
another. So in your case your sub should look something like this.

Sub Optimise()
on error goto Errorhandler
if MsgBox("ScreenUpdating?", vbYesNo) = vbNo then _
Application.ScreenUpdating = False

If (condition) Then
MySub1
ElseIf (condition) Then
MySub2
End If

ErrorHandler:
Application.ScreenUpdating = True
End Sub

Sub1 and Sub 2 should not do anything with the screen updating. The calling
procedure will take care of that. I have added an error handler which is a
good idea anytime you toggle application settings...
--
HTH...

Jim Thomlinson


"MichaelC" wrote:

I have a master Sub which calls in Sub routines in its body.
I want to be able to switch Screen.Updating on or off for ALL the main sub
and those subs referred to in it, but only answer the MsgBox once at the
beginning of the Sub.
How can I get the Answer to apply to all Subs?
Thanks in advance for your help.
Here is my code:
Sub Optimise()
Ans = MsgBox("ScreenUpdating?", vbYesNo)
Select Case Ans
Case vbYes
Application.ScreenUpdating = True
Case vbNo = False
Application.ScreenUpdating = False
End Select
If (condition) Then
MySub1
ElseIf (condition) Then
MySub2
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Application.ScreenUpdating MsgBox

This worked for me in Excel 2000

Public bol As Boolean

Sub CheckScreenUpdate()

Application.ScreenUpdating = bol

msgbox Application.ScreenUpdating
End Sub

Sub Optimise()
Dim Dim ans as Long
ans = MsgBox("ScreenUpdating?", vbYesNo)

If ans = 6 Then
bol = True
Else
bol = False
End If
'If (Condition) Then
'MySub1
'ElseIf (Condition) Then
'MySub2
'End If
End Sub


--
steveB

Remove "AYN" from email to respond
"MichaelC" wrote in message
...
I have a master Sub which calls in Sub routines in its body.
I want to be able to switch Screen.Updating on or off for ALL the main sub
and those subs referred to in it, but only answer the MsgBox once at the
beginning of the Sub.
How can I get the Answer to apply to all Subs?
Thanks in advance for your help.
Here is my code:
Sub Optimise()
Ans = MsgBox("ScreenUpdating?", vbYesNo)
Select Case Ans
Case vbYes
Application.ScreenUpdating = True
Case vbNo = False
Application.ScreenUpdating = False
End Select
If (condition) Then
MySub1
ElseIf (condition) Then
MySub2
End If
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Application.ScreenUpdating MsgBox

Thank you very much Jim and Steve. Your answers not only help me avoid
temporary insanity chasing my own tail, but also give me learnings for other
problems.

"Jim Thomlinson" wrote:

Once turned off the screen will not update until you turn it back on. A
common mistake is to turn it off at the beginning of every sub and back on at
the end of each sub. This will cause the screen to flash when one sub calls
another. So in your case your sub should look something like this.

Sub Optimise()
on error goto Errorhandler
if MsgBox("ScreenUpdating?", vbYesNo) = vbNo then _
Application.ScreenUpdating = False

If (condition) Then
MySub1
ElseIf (condition) Then
MySub2
End If

ErrorHandler:
Application.ScreenUpdating = True
End Sub

Sub1 and Sub 2 should not do anything with the screen updating. The calling
procedure will take care of that. I have added an error handler which is a
good idea anytime you toggle application settings...
--
HTH...

Jim Thomlinson


"MichaelC" wrote:

I have a master Sub which calls in Sub routines in its body.
I want to be able to switch Screen.Updating on or off for ALL the main sub
and those subs referred to in it, but only answer the MsgBox once at the
beginning of the Sub.
How can I get the Answer to apply to all Subs?
Thanks in advance for your help.
Here is my code:
Sub Optimise()
Ans = MsgBox("ScreenUpdating?", vbYesNo)
Select Case Ans
Case vbYes
Application.ScreenUpdating = True
Case vbNo = False
Application.ScreenUpdating = False
End Select
If (condition) Then
MySub1
ElseIf (condition) Then
MySub2
End If
End Sub

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
Using the Application.ScreenUpdating = False? Susan Hayes Excel Programming 1 January 29th 05 02:16 PM
Using the Application.ScreenUpdating = False? Susan Hayes Excel Programming 0 January 29th 05 03:50 AM
Question on application.screenupdating augustus Excel Programming 2 December 18th 04 01:35 AM
Application.screenUpdating = False Pamhall Excel Programming 1 December 17th 04 03:19 PM
problem with Application.ScreenUpdating Betty[_2_] Excel Programming 8 July 23rd 04 09:51 PM


All times are GMT +1. The time now is 10:33 AM.

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"