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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
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
 

ktab

Well-known Member
Joined
Apr 21, 2005
Messages
1,297
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
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
you're WELCOME :)

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

street1.house46_click
 

ktab

Well-known Member
Joined
Apr 21, 2005
Messages
1,297
Unless if you are a nomad; All the world is your house ;)

Thanks again
 

Forum statistics

Threads
1,136,927
Messages
5,678,621
Members
419,776
Latest member
mikelowski

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
Top