Showing Userform
Here's a sub to do it, just pass the userform name
Public Sub ShowUserFormByName(FormName As String)
Dim oUserForm As Object
On Error GoTo err
Set oUserForm = UserForms.Add(FormName)
oUserForm.Show
Exit Sub
err:
Select Case err.Number
Case 424:
MsgBox "The Userform with the name " & FormName & " was not
found.", vbExclamation, "Load userforn by name"
Case Else:
MsgBox err.Number & ": " & err.Description, vbCritical, "Load
userforn by name"
End Select
End Sub
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"IanC" wrote in message
...
Is it possible to use the show command for a userform, when the name of
the
userform is stored as variable. Basically, I have a userform that leads
off
to one of 10 other 'subforms' depending on the user's selection from a
dropdown. I have code that relies on If statements, etc, but it would be
easier when adding future 'sub-forms' if I could store all the userform
names
in an array and then select the appropriate name from there.
I have all the array code, but cannot work out the Show command.
|