+ Reply to Thread
Results 1 to 2 of 2

Want to run a macro before closing a workbook

  1. #1
    Registered User
    Join Date
    07-23-2007
    Posts
    20

    Want to run a macro before closing a workbook

    I want to run a macro before I close a workbook. This is because sometimes I forget to run the macro which causes my data to not be updated.

    Before the command for workbook close is executed, the macro is run

    Is it possible to do this?

    Thanks for your help

  2. #2
    Registered User
    Join Date
    03-12-2008
    Posts
    11
    this is possible using the VBE (ALT+F11)



    In order to get this code. Within VBE, select "This Workbook From the VBAProject Panel.

    On the code window you'll see a two drop down menus, one will read "(General)" click on here and select Workbook

    On the adjacent menu, choose "beforeClose"

    Excel will automatically put the code into the Editor for you as follows:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    'call your macro
    End Sub
    hth

+ 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