How to show User Form when form name is in string?

D

Don Wiss

If I want to reference a control by a string name I use:
Me.Controls("Checkbox" & i).Value

So, in VBA code how do I display a User Form with the form name in a
string? Application.Run ?

Don <www.donwiss.com> (e-mail link at home page bottom).
 
D

Doug Glancy

Don,

I could not remember how to do this, but Googling came up with this method:

VBA.UserForms.Add("UserForm1").Show

hth,

Doug
 
D

Dave Peterson

One way:

Option Explicit
Sub testme()
Dim myStr As String
Dim myUF As Object

myStr = "Userform1"
Set myUF = UserForms.Add(myStr)
myUF.Show
End Sub

Just in case you meant that you knew the userform's name (not as a string):

dim myUF as userform1
set myUF = new userform1
myuf.show
 

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