MrExcel Publishing
Your One Stop for Excel Tips & Solutions

In VBA, I want to call the Click event of a control on another worksheet...


Posted by Tuc on May 22, 2001 9:15 AM

In VBA, I want to call the Click event of a control on another worksheet.
Now ordinarily, I could put in code something like
Sheet4.CheckBox1_Click (provided that I had made the click event public)

What I want to be able to do is to refer to the worksheet a little bit more dynamically. Something like:
ActiveWorkbook.Worksheets("Sheet4").CheckBox1_Click.

Any suggestions?


Posted by Tim Francis-Wright on May 22, 2001 11:06 AM

You certainly can call the Click event code
from another procedure (as long as that Click
event code is public). Calling the click event
code does not change the value of the checkbox.

However, for checkboxes, Excel runs the click
event when you change the value of the checkbox,
even in VBA.

Hope that helps.
Tim F-W

Posted by Tuc on May 22, 2001 6:10 PM

Tim,
Thanks. Another thought would be to used the linkedcell property of the check box. That way I simply change the corresponding cell and that would also invoke the click event.
I appreciate you thinking about it.

Tuc

Posted by Tuc on May 24, 2001 6:41 AM

Forget about it.

This is a hassle. Here's what I did. I took all the code that I originally had in the Click event and put it into a separate procedure. I make that procedure public, and point both the Click event and the procedure that was going to call that click event to the new public procedure. It's a work around, but certainly easier to understand and work with. C'est La Vie!