after combobox entry show userform

flash3000

New Member
Joined
Nov 16, 2005
Messages
16
made a combobox with entrypossibility yes and no.
When yes is entered I want Userform1 to show up.
When no is entered I want Userform2 to show up.
Can somebody give me the full code?
What I have now is:

Private Sub ComboBox1_DropButtonClick()
ComboBox1.AddItem "yes"
ComboBox1.AddItem "no"
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Code:
Private Sub CommandButton1_Click()
    If ComboBox1.Value = "yes" Then
        UserForm1.Show
    ElseIf ComboBox1.Value = "no" Then
        UserForm2.Show
    End If
    
    
End Sub



Private Sub UserForm_Initialize()
ComboBox1.AddItem "yes"
ComboBox1.AddItem "no"

End Sub
 
Upvote 0
Hello, flash3000
Welcome to the Board !!!!!

before answering some remarques
why do you use a combobox for this ? wouldn't two optionbuttons do ?

your code will add over and over ye and no to the list
you can use
Code:
Private Sub ComboBox1_DropButtonClick()
ComboBox1.List = Array("yes", "no")
End Sub

your question
Code:
Private Sub ComboBox1_Click() 'or ComboBox1_Change
If ComboBox1 = "yes" Then UserForm1.Show
If ComboBox1 = "no" Then UserForm2.Show
ComboBox1.Clear
End Sub
using "clear" allows to select again the same value

kind regards,
Erik
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top