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

This month, every Windows Secrets subscriber can download a one-chapter excerpt of Windows 7: The Missing Manual.Windows 7: The Missing Manual provides valuable information to help you overcome these difficulties in learning a new operating system. Subscribe today to download your free excerpt.
Put your macro in the workbook_BeforeClose event.
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
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.
Worked great thanks for the help!
- Randy