Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jan 2001
    Location
    VA, USA
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro execution at close

    Is there a way (Excel '97 SR2)to automatically run a macro when you close a worksheet.
    Thanks!
    Randy

  2. #2
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Kortrijk, Belgium
    Posts
    571
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro execution at close

    Put your macro in the workbook_BeforeClose event.

  3. #3
    New Lounger
    Join Date
    Jan 2001
    Location
    VA, USA
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro execution at close

    I hate to say this, but I have not been able to find where the workbook_beforeclose event lives. I have been through the options and help, but no reference. Is this possibly an Office 2000 feature, if so, I'm on Excel '2000.
    Thanks
    Randy

  4. #4
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Kortrijk, Belgium
    Posts
    571
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro execution at close

    You should select the Visual Basic Editor (via Tools >> Macro >> Visual Basic Editor); then in the project explorer (if not visible, make it visible via Vies >> Project Explorer), find the VBAproject of your workbook. In the VBAproject, you should find Microsoft Excel Objects, under which you should see ThisWorkbook. Double click ThisWorkbook , this will open the General (see left dropdown box) code module. In the left dropdown box, select Workbook. In the right dropdown box, you should find the BeforeClose event.

  5. #5
    New Lounger
    Join Date
    Jan 2001
    Location
    VA, USA
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro execution at close

    Worked great thanks for the help!

    - Randy

Posting Permissions

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