UserForm

E

Ed

I hope that I can make this make sense.

I have several user forms called, e.g., "UserForm1" through "UserForm50"

I want to set a variable called "FormIs" to represent one of the user
forms. I want to select the appropriate user form from a dropdown list that
I have created, populated with the 50 UserForm names.

I have assign to the result of my selection from the dropdown list to
the variable SelectedName. The return value of SelectedName is a string
variable. SelectedName might have a value of "UserForm17", but that is not
the same as the form UserForm17.

I know how to assign FormIs to the actual object UserForm17. I just
type:
Set FormIs = UserForm17

But assigning FormIs to a string variable SelectedName cannot be done by
merely typing:
Set FormIs = SelectedName (because SelectedName is a variable, not an
object)

How can I convert FormIs or SelectedName to the actual object I want it
to represent?
 
E

Ed

Hi Ed,

Until a better suggestion comes along ...

You might be able to use a Select Case statement, e.g.

Dim FormIs as Object
....
....

Select Case SelectedName
Case "UserForm1"
Set FormIs = New UserForm1
Case "UserForm2"
Set FormIs = New UserForm2
...
...
End Select

Regards.

(Another) Ed
 
E

Ed

Ed-

Brilliant! Thanks.

(other) Ed

"Ed"

Hi Ed,

Until a better suggestion comes along ...

You might be able to use a Select Case statement, e.g.

Dim FormIs as Object
...
...

Select Case SelectedName
Case "UserForm1"
Set FormIs = New UserForm1
Case "UserForm2"
Set FormIs = New UserForm2
...
...
End Select

Regards.

(Another) Ed
 

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

Top