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?
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?