Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2019, 05:02 PM
poetofpiano poetofpiano is offline Application.ScreenUpdating Question Windows 10 Application.ScreenUpdating Question Office 2016
Novice
Application.ScreenUpdating Question
 
Join Date: Sep 2015
Posts: 25
poetofpiano is on a distinguished road
Default Application.ScreenUpdating Question

Obviously you can use Application.ScreenUpdating to speed up the performance of an intensive macro:



Code:
Application.ScreenUpdating = False
    ' code of macro
Application.ScreenUpdating = True
My question is, what if you use Exit Sub somewhere in the middle of the macro? Do you then also need to put Application.ScreenUpdating = True in the middle of the macro, before the Exit Sub, as follows:

Code:
Application.ScreenUpdating = False
    ' code of macro
    Application.ScreenUpdating = True
    Exit Sub
    ' more code of macro
Application.ScreenUpdating = True
I have never added this third instance, but lately I have noticed Word using a steady 7% CPU usage, and in the Task Manager, the "Print driver host for applications" is displayed under the Word application whenever the high CPU takes place. I’m not sure if the two issues are related; if anyone has any suggestions, thanks so much!
Reply With Quote
  #2  
Old 09-18-2019, 09:09 PM
gmayor's Avatar
gmayor gmayor is offline Application.ScreenUpdating Question Windows 10 Application.ScreenUpdating Question Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I prefer not to use exit sub, but goto a label at the end of the macro where the macro is tidied up e.g. as follows

Code:
Sub Macro1()
Dim orng As Range
    Application.ScreenUpdating = False
    ' code of macro
    GoTo lbl_Exit
    ' more code
lbl_Exit:
    Application.ScreenUpdating = True
    Set orng = Nothing
    Exit Sub
End Sub
I cannot comment on the CPU use.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.ScreenUpdating Question Application.ScreenUpdating not working? Welshgasman Word VBA 3 05-02-2017 08:42 AM
Application.ScreenUpdating Question Macro Needed to Insert Asnwer to A Question in Multiple Choice Format Question rsrasc Word VBA 7 03-28-2014 12:28 PM
Application.ScreenUpdating Question What application to use? pfergy Office 1 03-12-2011 08:46 PM
Application.ScreenUpdating Question Best application to use? FrankW Office 2 06-13-2009 01:16 AM
Categories question & replying with attachment question glitzymama Outlook 0 03-15-2006 09:32 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft