Results 1 to 4 of 4

Application.ScreenUpdating

Threaded View

  1. #1
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Application.ScreenUpdating

    Sometimes it is necessary in code to switch off ScreenUpdating to speed things up & prevent "screen flickers". It is also useful to switch off Calculation to speed things up.

    This code will capture the user's current settings & replstore them after the code has run,

    Option Explicit
    
    '---------------------------------------------------------------------------------------
    ' Procedure : myMacro
    ' DateTime  : 09/05/2008 08:56
    ' Author    : Roy Cox
    ' Website   : www.excel-it.com for more examples and Excel Consulting
    ' Purpose   : switch off application settings & restore after code has run
    ' Disclaimer; This code is offered as is with no guarantees. You may use it in your
    '             projects but please leave this header intact.
    
    '---------------------------------------------------------------------------------------
    '
    Sub myMacro()
        'declare boolean variables to store the user's settings
        Dim bScreenUpdating As Boolean
        Dim bDisplayAlerts As Boolean
        Dim bEnableEvents As Boolean
        Dim lCalculate As Long
        'set the variables
        With Application
            bScreenUpdating = .ScreenUpdating
            bDisplayAlerts = .DisplayAlerts
            bEnableEvents = .EnableEvents
            lCalculate = .Calculation
    
            'your code here
    
            'restore settings
            .ScreenUpdating = bScreenUpdating
           .DisplayAlerts = bDisplayAlerts
           .EnableEvents = bEnableEvents
            .Calculate = lCalculation
        End With
    
    End Sub
    Last edited by royUK; 05-16-2008 at 02:25 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1