Posted to microsoft.public.excel.programming
|
|
Call a UserForm based on ComboBox selection
Exactly what are options A and B supposed to do?
Rick
"DJ" wrote in message
...
Hi Chip,
I tried the simpler idea, and got no respone (no error, no UserForm). Do
all possible cases need to be listed in the macro?
DJ
"Chip Pearson" wrote:
Try something like
Select Case UCase(Selection.Text)
Case "A"
Userform1.Show
Case "B"
Userform2.Show
' and so on
End Select
If you want to get a bit trickier, you can use code like
Sub AAA()
Dim N As Long
Dim Obj As Object
N = 3
Select Case N
Case 1
Set Obj = VBA.UserForms.Add("Userform1")
Case 2
Set Obj = VBA.UserForms.Add("Userform2")
Case 3
Set Obj = VBA.UserForms.Add("Userform3")
End Select
If Not Obj Is Nothing Then
Obj.Show
End If
End Sub
See http://www.cpearson.com/Excel/showanyform.htm for an explanation.
--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
"DJ" wrote in message
...
Ive created a worksheet ComboBox that contains options A, B, and C.
When
option C is selected, I would like UserForm1 to appear. I am having
trouble
calling the user form. I have tried variations of the following:
Private Sub Options_Click()
'If TypeName(Selection) = "C" Then Load UserForm1
End Sub
Any help is much appreciated!
DJ
|