Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Zach,
While this will work just fine, my preference is to not call one event handler from another. Instead I would create a class or a module, put the common code in a helper method that gets called from both event handlers. The reason for this is that if for some reason you change or remove Button1 then Button2 will be ignorant since it's now decoupled from Button1. for Example: Sub Button1_Click() Call HelperMethod() End Sub Sub Button2_Click() Call HelperMethod() End Sub Sub HelperMethod() ' Put your common code here. End Sub - Al "Jim Thomlinson" wrote: You need to fully declare where the command button lives otherwise how would the program know where to look. You could have the same command button on 2 or more sheets... Give this a try. Call Sheet1.Command1_Click() or Call Sheets("My Sheet").Command1_Click() You are correct that the procedure needs to be public so leave that as it is. -- HTH... Jim Thomlinson " wrote: Hi all- I have a command button on Sheet1, with a Command1_Click() method. I want to call that procedure from the Command2_Click() method which is on Sheet2. Even with both procedures defined as Public, I am unable to get this to work. I have tried Call Command1_Click() Call Command1.click I get "Sub or function not defined" for Command1_Click() & "Object Required" for Command1.click. Any thoughts? Thank you in advance! Zacah |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unable to click on charts & unable to create any new charts Excel | Charts and Charting in Excel | |||
GetObject method not work after Call Shell Method | Excel Programming | |||
Unable to call external program/dll | Excel Programming | |||
How do I call a method in VB from Excel with JUST code? | Excel Programming | |||
How do I call a method in VB from Excel with JUST code? | Excel Programming |