ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   BeforeClose event won't run when closing using macro (https://www.excelbanter.com/excel-programming/412214-beforeclose-event-wont-run-when-closing-using-macro.html)

ETLahrs

BeforeClose event won't run when closing using macro
 
I am using 2 workbooks in this example. I have the main log and I have
individual sheets for each employee. Since some people can't even comprehend
copy/paste, I am making a macro to select the range from their individual
sheet, copy and paste it into the main sheet, and then close the main sheet.

The problem I am having is this. In the main sheet, I have a beforeClose
event. The event works fine when you manually close the workbook, however
when the macro from the individual's workbook closes the sheet, the
beforeClose event doesn't run.

Why would this be?

Also, I did both, write the code myself and record a macro using the excel
tool. When I recorded the macro, the beforeClose event ran without any
problems.

Any help would be greatly appreciated.

Thanks,
Ed

Jim Rech

BeforeClose event won't run when closing using macro
 
when the macro from the individual's workbook closes the sheet

The only thing that would stop before_close from running is if this macro
had an Application.EnableEvents = False in it. I'd check for that.

--
Jim
"ETLahrs" wrote in message
...
|I am using 2 workbooks in this example. I have the main log and I have
| individual sheets for each employee. Since some people can't even
comprehend
| copy/paste, I am making a macro to select the range from their individual
| sheet, copy and paste it into the main sheet, and then close the main
sheet.
|
| The problem I am having is this. In the main sheet, I have a beforeClose
| event. The event works fine when you manually close the workbook, however
| when the macro from the individual's workbook closes the sheet, the
| beforeClose event doesn't run.
|
| Why would this be?
|
| Also, I did both, write the code myself and record a macro using the excel
| tool. When I recorded the macro, the beforeClose event ran without any
| problems.
|
| Any help would be greatly appreciated.
|
| Thanks,
| Ed




All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com