+ Reply to Thread
Results 1 to 4 of 4

Calculation macro upon opening and closing

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,702

    Calculation macro upon opening and closing

    Hi,

    I have a spreadsheet in which I need it to run a macro upon opening.

    If possible whenever the spreadsheet is opened I require the following to be actioned:

    Tools>Options>Calculation to be set to Manual and recalculate to be unchecked

    And then upon exiting the spreadsheet the macro would need to turn automatic calculation back on.

    Can anyone suggestions with the VBA code?

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Hi, Paul.

    Right-click on the Excel icon next to the File menu, then select View Code, and copy the following code:

    Private Sub Workbook_Open()
        With Application
            .Calculation = xlManual
            .CalculateBeforeSave = False
        End With
    End Sub
    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Application.Calculation = xlCalculationAutomatic
    End Sub
    HTH

    Jason

  3. #3
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,702
    Brilliant, it worked a treat. Thank You

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Glad it helped.

    Jason

+ Reply to Thread

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