Selection of UserForm through button

S

saziz

Hi All,
I have this code working for selecting a userform:

Private Sub CommandButton1_Click()
If Button = OptionButton1 Then

UserForm1.Show

ElseIf Button = OptionButton2 Then
UserForm2.Show
End If

End Sub




Now I want to add a 3rd. button. I tried inserting another if
statement but it does not show my new user form.

Any help would be apreicated
Thanks
Syed
 
S

saziz

Hi alok,
Here is the code:

Private Sub CommandButton1_Click()
If Button = OptionButton1 Then
UserForm1.Show
End If
If Button = OptionButton2 Then
UserForm2.Show
End If
If Button = optionbutton4 Then
UserForm4.Show
End If

End Sub

What is happening is when I select a button, it shows all 3 userforms
one by one.
Syed
 
N

Norman Jones

Hi Saziz

Try:

'=============>>
Private Sub CommandButton1_Click()
If OptionButton1 Then
UserForm1.Show
ElseIf OptionButton2 Then
UserForm2.Show
ElseIf OptionButton4 Then
UserForm4.Show
End If
End Sub
'<<=============
 

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

Similar Threads


Top