ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dueling events (https://www.excelbanter.com/excel-programming/394685-dueling-events.html)

XP

Dueling events
 
Using Office 2003 and Windows XP:

I've been slamming it pretty hard today and maybe I'm just tired, but I'm
having a conflict between events in a workbook and although I'm positive
there is an easy solution, I can't see it right now.

I have the following functions in my ThisWorkbook module:

Workbook_Open contains Function_1 and Function_2
Workbook_Activate contains Function_1 and Function_3

Workbook_Deactivate contains Function_4 and Function_5
Workbook_BeforeClose contains Function_4 and Function_6

How can I keep these functions from duplicating one another. When the user
opens the workbook, the above will fire function 1 twice, causing a problem.
When the user closes the file, function 4 will fire twice; yet when the user
switches between workbooks (or opens or closes the file), I need functions 1
and 4 to run once for their respective events...how can I accomplish this?

Thanks again for your help...

John Bundy

Dueling events
 
By what you write, it is firing on the open and the activate, and on close
and deactivate, why not just take the function out of the open and close?
Following what you wrote the activation and deactivation should take care of
it.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"XP" wrote:

Using Office 2003 and Windows XP:

I've been slamming it pretty hard today and maybe I'm just tired, but I'm
having a conflict between events in a workbook and although I'm positive
there is an easy solution, I can't see it right now.

I have the following functions in my ThisWorkbook module:

Workbook_Open contains Function_1 and Function_2
Workbook_Activate contains Function_1 and Function_3

Workbook_Deactivate contains Function_4 and Function_5
Workbook_BeforeClose contains Function_4 and Function_6

How can I keep these functions from duplicating one another. When the user
opens the workbook, the above will fire function 1 twice, causing a problem.
When the user closes the file, function 4 will fire twice; yet when the user
switches between workbooks (or opens or closes the file), I need functions 1
and 4 to run once for their respective events...how can I accomplish this?

Thanks again for your help...



All times are GMT +1. The time now is 10:29 AM.

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