Help with Userform ComboBoxes

JADownie

Active Member
Joined
Dec 11, 2007
Messages
395
Hello -

I have setup a userform with 6 different combo boxes for users to make selections from and a Submit button.

I have macros setup for each of the comboboxes similar to what I am showing here below.

Essentially, each combobox has choices from 1-4, and then those choices are linked to an autofilter macro. So as an example, if the user selects Financial Services, then the form should run macro Team_1.

I would like for the user to be able to makle their selections on the userform, and then click Submit, and that would then run the appropriate macro based on the users selections on the form, and display the filtered data.

I am strugglig now with programming my Submit button to basically read the inputs for the 6 comboboxes, and execute the appropriate macro. Could someone please help me with this first one? I know that once I see the code written, I will understand it, and be able to replicate for my other comboboxes.

Thanks SO much in advance for your help here today!! :)

Private Sub ComboBox1_Change()
If Me.ComboBox2.Value = "Financial Services" Then
Call Team_1

ElseIf Me.ComboBox2.Value = "Consumer" Then
Call Team_2

ElseIf Me.ComboBox2.Value = "Tel/Tech" Then
Call Team_3

ElseIf Me.ComboBox2.Value = "B&C" Then
Call Team_4

End If

End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi,

If the "Summit" command button is Name "Summit" the you should do some thing like this

Code:
Private Sub Summit_Click()
If Me.ComboBox2.Value = "Financial Services" Then
Call Team_1

ElseIf Me.ComboBox2.Value = "Consumer" Then
Call Team_2

ElseIf Me.ComboBox2.Value = "Tel/Tech" Then
Call Team_3

ElseIf Me.ComboBox2.Value = "B&C" Then
Call Team_4

End If

End Sub
 
Upvote 0
Thanks!

I have used this code here for my CommandButton1, but when I click the button, nothing seems to be executing....

Private Sub CommandButton1_Click()

If Me.ComboBox2.Value = "Financial Services" Then
Call Team_1

ElseIf Me.ComboBox2.Value = "Consumer" Then
Call Team_2

ElseIf Me.ComboBox2.Value = "Tel/Tech" Then
Call Team_3

ElseIf Me.ComboBox2.Value = "B&C" Then
Call Team_4

End If

End Sub
 
Upvote 0
Have you checked that the values in the code match those in the combobox?
 
Upvote 0
Thanks! Yes, I have double checked the spelling and made sure that there were no leading or extra spaces.... Seems like it should work
 
Upvote 0
Just changed them all from Me to userform1 and still nothing runs when I click the button

Private Sub CommandButton1_Click()

If UserForm1.ComboBox2.Value = "Financial Services" Then
Call Team_1

ElseIf UserForm1.ComboBox2.Value = "Consumer" Then
Call Team_2

ElseIf UserForm1.ComboBox2.Value = "Tel/Tech" Then
Call Team_3

ElseIf UserForm1.ComboBox2.Value = "B&C" Then
Call Team_4

End If

End Sub
 
Upvote 0
Where did you put the code?

Is there something selected in ComboBox2 when the code runs?

Does the code run? You can check that by putting a break point on the first line with F9.
 
Upvote 0
Try adding one testing line at the start of the routine.
Code:
MsgBox Me.ComboBox2.Text

Also, = is case sensitive in VBA, might that be an issue?
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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