Call a private userform's event

ktab

Well-known Member
Joined
Apr 21, 2005
Messages
1,297
Hello,

Is it possible to call a private userform procedure with the "call" command (or anything else like application.run ) from an outside of the userform, module?
What I mean is that i want, through a procedure called e.g. public sub test() to execute commandbutton18_click event. (button 18 belongs to userform1.

Thank you
Kostas
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi, Kostas,

yes, you can do that

change "Private" to "Friend" or "Public"
Code:
Friend Sub CommandButton1_Click()
MsgBox "This is codemodule """ & Me.Name & ".CommandButton1_Click""", 64, "INFO"
End Sub
in any module use
Code:
UserForm1.CommandButton1_Click
kind regards,
Erik
 
Upvote 0
Thank you Erik,
I went half way (renamed to public sub commandbutton1_click()) but just called commandbutton1_click() not userform1.commandbutton1_click()

Thank you very much for your assistance
 
Upvote 0
you're WELCOME :)

going to house n°46 doesn't make much sense ...
you need the street in your address !

street1.house46_click
 
Upvote 0
Unless if you are a nomad; All the world is your house ;)

Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top