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
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

iggydarsa

Well-known Member
Joined
Jun 28, 2005
Messages
1,647
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
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,084
Messages
5,570,128
Members
412,305
Latest member
Mozz
Top