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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,133
Messages
5,835,594
Members
430,369
Latest member
pingel

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
Top