Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA: How do I call a button click event from a macro? 1

Status
Not open for further replies.

btorrean

Programmer
Apr 9, 2007
2
US
Hi,
I'm having trouble calling the click event of a button on a UserForm from another macro. The button's name is "cmdCalc1" and it's on form "frmRunTimeCalc". I'm trying to call the event from module "Module5". I've tried all sorts of things like using the following code in Module5:
Code:
frmRunTimeCalc.cmdCalc1_Click
or
frmRunTimeCalc.cmdCalc1_Click()
or
Call frmRunTimeCalc.cmdCalc1_Click
I got errors with all of those. I've also tried recording a macro while performing the operations and the macro came up empty. Anyone have any ideas??

Brian
 
btorrean,
If you change the declaration from Private to Public [tt]frmRunTimeCalc.cmdCalc1_Click[/tt] should work.

Code:
[b]Public[/b] Sub cmdCalc1_Click()
...

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT+08:00) Singapore
 
CMP,
Thanks so much! It works perfectly! Really appreciate it!

Brian
 
I am having same problem, but not successful.
I have a Sheet1 with a cmdStart_click().
I need this event to start when Excel 2002 is opened.
Pls. advise on how to make this happen.

thx..bt7403
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top