Closed Thread
Results 1 to 4 of 4

Set macro to run automatically when closing workbook?

  1. #1
    Wuddus
    Guest

    Set macro to run automatically when closing workbook?

    I have a macro that ideally would run automatically whenever the user closes
    out of the workbook. I know how to set a macro to run this way when OPENING
    the workbook, but is the reverse possible?

  2. #2
    Paul B
    Guest

    Re: Set macro to run automatically when closing workbook?

    Wuddus,

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    'your code
    End Sub

    --
    Paul B
    Always backup your data before trying something new
    Please post any response to the newsgroups so others can benefit from it
    Feedback on answers is always appreciated!
    Using Excel 2002 & 2003

    "Wuddus" <[email protected]> wrote in message
    news:[email protected]...
    >I have a macro that ideally would run automatically whenever the user
    >closes
    > out of the workbook. I know how to set a macro to run this way when
    > OPENING
    > the workbook, but is the reverse possible?




  3. #3
    Forum Contributor
    Join Date
    05-11-2006
    Posts
    104
    Yes it's possible,

    Go to the Visual Basic Editor, select This Workbook by double clicking.

    In the box that appears on the left hand side select Workbook and on the right hand side select BeforeClose

    Then put your macro code inbetween this and it will run before you close the worksheet.

    Hope this does what you're after
    Regards

    Carl

  4. #4
    Wuddus
    Guest

    Re: Set macro to run automatically when closing workbook?

    Thanks! I didn't know about that one at all. (And thanks for the fast reply,
    too: Maybe I can get this thing done this morning yet!)

    "Paul B" wrote:

    > Wuddus,
    >
    > Private Sub Workbook_BeforeClose(Cancel As Boolean)
    > 'your code
    > End Sub
    >
    > --
    > Paul B
    > Always backup your data before trying something new
    > Please post any response to the newsgroups so others can benefit from it
    > Feedback on answers is always appreciated!
    > Using Excel 2002 & 2003
    >
    > "Wuddus" <[email protected]> wrote in message
    > news:[email protected]...
    > >I have a macro that ideally would run automatically whenever the user
    > >closes
    > > out of the workbook. I know how to set a macro to run this way when
    > > OPENING
    > > the workbook, but is the reverse possible?

    >
    >
    >


Closed 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