Dependant comboBoxes in UserForm

GColeman

New Member
Joined
Feb 16, 2016
Messages
34
Office Version
  1. 2016
Platform
  1. Windows
Ok wonderful people. I have a sheet where I'm keeping track of ticket sales. There are a large number, and wide variety. They fall into 3 categories, H, T, and D.

The userform has a number of text boxes and combo boxes. One of which, I'd like to have dependent on the one before it. It saves me from entering in 100 'AddItem." and having to manually go in every time there is a change. I'd just edit the master list once, and be done.

Here is what I have:

Private Sub UserForm_Activate()
'Populate combobox.

Dim rngEmp As Range
Dim rngType As Range
Dim rngRst As Range

Dim ws As Worksheet

Set ws = Worksheets("Sheet2")

For Each rngEmp In ws.Range("EmployeeList")
Me.cboEmp.AddItem rngEmp.Value
Next rngEmp

For Each rngType In ws.Range("TypeList")
Me.cboType.AddItem rngType.Value
Next rngType

For Each rngRst In ws.Range("ResultList")
Me.cboRst.AddItem rngRst.Value
Next rngRst

End Sub
_________________________________________________________________

Private Sub cboStyle_Change()
Dim index As Integer
index = cboType.ListIndex
cboStyle.Clear

Select Case index
Case Is = ("HC")

With cboStyle
For Each rngStyle In ws.Range("HC")
Me.cboCharge.AddItem rngCharge.Value
Next rngStyle
End With

Select Case index
Case Is = ("TC")

With cboStyle
For Each rngStyle In ws.Range("TC")
Me.cboStyle.AddItem rngStyle.Value
Next rngStyle
End With

Select Case index
Case Is = ("DC")

With cboStyle
For Each rngStyle In ws.Range("DC")
Me.cboStyle.AddItem rngStyle.Value
Next rngStyle
End With

End Select
End Sub


When I run it, I get End Sub highlighted and "End Case without End Select"

Now at this point I've butchered it from the original version, trying to find what is throwing it off. But I always get either the above error, or some thing similar.

Is there a way to make this work? Or a better way?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Still looking for any help on this. I left it for a bit and came back to it. Tried a few variations.
At this point I would settle for the second Combobox dependent on the first, as long as it is filled by a dynamic range. The rest I can fill with AddItem. Any help is greatly appreciated
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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