vba for excel

  • Thread starter Thread starter Yehuda
  • Start date Start date
Y

Yehuda

How can I make subs in Userform modules be available in
standard modules?

I think it might have something to do with declaration,
but I have problems doing it.

Thanks for helping.

Yehuda
 
You need to put the subs in general modules and call them from the userform
module if you need to do this.
 
To do this 'cleanly' not only should the procedure be
public, but the userform ought to be loaded into memory

Sub test()
Dim temp As UserForm1
Set temp = New UserForm1
Load temp
temp.helloworld

Unload temp
Set temp = Nothing
End Sub

Calling the procwill by default force open the userform

In general, place important subs in a standard module,
make sure that they're public , then you code in other
modules etc will be able to use them.
If you don't wanta public sub available to the macro list
on the workbook, then mark the module as

Option Private Module

Patrick Molloy
Microsoft Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top