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

I've been scratching my head how to solve this problem.

Say I have a MacroA which is something like this:

Sub MacroA()
Application.ScreenUpdating = False
Code
Application.ScreenUpdating = True
End Sub

There'll not be any screen flicker when MaroA is run. Everything is sweet.
Now there's a second macro which will run MacroA on all the worksheets:

Sub MacroA_AllSheets()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Activate
Call MacroA
Next ws
End Sub

For this second macro, however I put in the Application.ScreenUpating
statements, the screen will still display the macro cycling through all the
worksheets. For example, the following does NOT solve the problem:

Sub MacroA_AllSheets()
Dim ws As Worksheet
For Each ws In Worksheets
Application.ScreenUpdating = False
ws.Activate
Call MacroA
Application.ScreenUpdating = False
Next ws
Application.ScreenUpdating = True
End Sub

The only way I can solve the problem is by deleting
Application.ScreenUpdating = True in MacroA, i.e.

Sub MacroA()
Application.ScreenUpdating = False
Code
End Sub

However I am not sure if this is what I want to do because I am not sure if
that means I'll be turning off ScreenUpating for good.

Any advice will be much appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Screen Updating Problem

Sub MacroA_AllSheets()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In Worksheets

ws.Activate
Call MacroA

Next ws
Application.ScreenUpdating = True
End Sub

How to handle ScreenUpdating in MacroA depends on how else it may be called
in your project, lets say you have the above and somewhere else simply this

Sub MacrA_ActiveSheet
'best to disable screenupdating here
' but for some reason don't want to
Call MacroA
End Sub


Sub MacroA()
Dim bScrUpdating As Boolean
bScrUpdating = Application.ScreenUpdating
Application.ScreenUpdating = False
Code
If bScrUpdating then
Application.ScreenUpdating = True
End If
End Sub

Regards,
Peter T

"Shatin" wrote in message
...
I've been scratching my head how to solve this problem.

Say I have a MacroA which is something like this:

Sub MacroA()
Application.ScreenUpdating = False
Code
Application.ScreenUpdating = True
End Sub

There'll not be any screen flicker when MaroA is run. Everything is sweet.
Now there's a second macro which will run MacroA on all the worksheets:

Sub MacroA_AllSheets()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Activate
Call MacroA
Next ws
End Sub

For this second macro, however I put in the Application.ScreenUpating
statements, the screen will still display the macro cycling through all

the
worksheets. For example, the following does NOT solve the problem:

Sub MacroA_AllSheets()
Dim ws As Worksheet
For Each ws In Worksheets
Application.ScreenUpdating = False
ws.Activate
Call MacroA
Application.ScreenUpdating = False
Next ws
Application.ScreenUpdating = True
End Sub

The only way I can solve the problem is by deleting
Application.ScreenUpdating = True in MacroA, i.e.

Sub MacroA()
Application.ScreenUpdating = False
Code
End Sub

However I am not sure if this is what I want to do because I am not sure

if
that means I'll be turning off ScreenUpating for good.

Any advice will be much appreciated.



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
Problem with Splash Screen user form with updating status [email protected] Excel Programming 2 April 18th 07 03:38 PM
Screen Updating problem with nested subroutines Atreides Excel Programming 4 February 7th 07 05:25 AM
Screen Updating Ben[_10_] Excel Programming 2 October 22nd 05 12:06 AM
Screen updating Mark Stephens Charts and Charting in Excel 0 February 18th 05 03:55 PM
Screen Updating SmilingPolitely Excel Programming 4 April 14th 04 04:17 PM


All times are GMT +1. The time now is 06:53 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"