Calling commandbutton_click event from a module

aman

Registered User.
Local time
Today, 01:05
Joined
Oct 16, 2008
Messages
1,251
I have written the code on the commandbuttons click event and the code is present in the userform . Now Just wondering if its possible to call commandbutton_click event from the module. Like is there any want I can use from the module:
Code:
call commandbutton1_click

Thanks
 
if 'the module' is the same form module as commandbutton1_click then yes you can.

If it is a different module you need to replace private with public for the commandbutton1_click sub and the form itself needs to be open.

And to call it you would use

Form_whatevermyformiscalled.commandbutton1_click
 
just realised from your other post that you are working in Excel, not Access so I don't know if my suggestion would work

you could put the code behind the button in a general module and then you can call it from anywhere (providing it is not referencing anything on the form)
 

Users who are viewing this thread

Back
Top Bottom