BrianExcel
Well-known Member
- Joined
- Apr 21, 2010
- Messages
- 975
For some reason I cannot get this code to work. I have 5 options in a combo box that a user can select. let's call them 1, 2, 3, 4 and 5.
The point of my code is to populate a listbox with the appropriate values depending on what's selected in the combo box. If they select 1, populate the range r1. If they select "2" then populate range r2 and so on.
The following code is what I'm trying, but when I run the code (set to the CHANGE event on the combo box) it gives the error: "Compile error: Statements and labels invalid between Select Case and first case."
Can anyone help?
The point of my code is to populate a listbox with the appropriate values depending on what's selected in the combo box. If they select 1, populate the range r1. If they select "2" then populate range r2 and so on.
The following code is what I'm trying, but when I run the code (set to the CHANGE event on the combo box) it gives the error: "Compile error: Statements and labels invalid between Select Case and first case."
Can anyone help?
Code:
Private Sub cmbSize_Change()
Select Case 1
UserForm1.lbxStock.RowSource = r1
Case 2
UserForm1.lbxStock.RowSource = r2
Case 3
UserForm1.lbxStock.RowSource = r3
Case 4
UserForm1.lbxStock.RowSource = r4
Case 5
UserForm1.lbxStock.RowSource = r5
End Select
End Sub