×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Excel: Open a UserForm with defined name

Excel: Open a UserForm with defined name

Excel: Open a UserForm with defined name

(OP)
Hi,

I'm new to the forums and i have (what i think to be) a fairly simple question...

In my code, i have a variable that represents the name of the UserForm that will be opened.  How can I open the appropriate existing form based on this string representing the form name?  

For instance, FormName = "UserForm_2"

Therefore, I want to open the existing form 'UserForm_2'.

I don't want to simply use UserForm_2.show because the value of the string (and therefore the form to be opened) will programmatically change depending on the circumstances.

Any ideas??

My first guess would be to use UserForm(FormName).Show , but this is not a built in function.

Thanx!

RE: Excel: Open a UserForm with defined name

dsantist,

You can call userform by the index

CODE

UserForms.item(i).show
For more control in useform numbering define array of userform objects:

CODE

dim A(1 to 10) as Object
...
set A(1) = Userform1
...
set A(10) = Userform10
...
A(1).show
You cannot call Userforms("formname1").show like worksheets("Sheet1"). For more information search userform collection in VBA help.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources