?
Solved

Odd ScreenUpdating=False Problem

Posted on 2014-09-25
8
Medium Priority
?
134 Views
Last Modified: 2014-10-01
Hi Experts, I'm in excel 2007 experiencing a weird issue.
Please open the attached workbook.

Please try clicking any of the navigation buttons. You'll see that as you navigate between sheets a box will appear highlighting the used range before switching worksheets. That is because of the following code to set the zoom on each sheet:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'set zoom for active sheet to columns with data
 ActiveSheet.UsedRange.Resize(ActiveSheet.UsedRange.Columns.Count).Select
 ActiveWindow.Zoom = True: ActiveWindow.VisibleRange(1, 1).Select
End Sub

Open in new window

Now what's odd is that on Workbook_Open I have set ScreenUpdating equal to false see the below code:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Call FormatWorkbook
'activate StandardMode
Sheets("StandardMode").Activate
End Sub

Open in new window

I've discovered that if I add another Application.ScreenUpdating = False statement to the zoom code it will work....... but why would I have to set it to false twice? Is it being set to true after Workbook Open somehow?
EESafe-UI-Input-09.24.xlsm
0
Comment
Question by:-Polak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 40344291
It's a quirk but ScreenUpdating always sets itself to True at the and of any routine.
0
 
LVL 49

Assisted Solution

by:Martin Liss
Martin Liss earned 2000 total points
ID: 40344298
And you can prove it by creating these two macros. Run x and then run y.
Sub x()
Application.ScreenUpdating = False
End Sub

Sub y()
MsgBox Application.ScreenUpdating
End Sub

Open in new window

0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 40344304
Does that mean you don't have to consciously put:

Application.ScreenUpdating = True

At the end of a routine?

Thanks
Rob H
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 49

Expert Comment

by:Martin Liss
ID: 40344318
That's correct, but I do it anyhow for clarity.
0
 
LVL 1

Author Closing Comment

by:-Polak
ID: 40344352
Well alrighty then!
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40344368
I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 40344387
I guess I am thinking of times when I have included a Stop command in the script so have then had to manually reset the Screen Update to True
0
 
LVL 1

Author Comment

by:-Polak
ID: 40354923
Hey guys, just a heads up on this, while it does seem to set itself back to true in every other circumstance; if you don't have it set to true at the end of a subroutine and then insert another worksheet it will appear as if excel has frozen. (this was excel 2007)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question