Hi All,
I have one combo box supplying the row source to another combo box. I am using define range in the first combo box to achieve this. Everything is working well except for when combobox1 is blank or does not have a matching named range.
Combo box 1 has a row source of sheet1!A2:A33. the data in the Cells sheet1!A2:A33 has a range match for each of the 31 line items.
When I select an item and combobox1 it supplies combobox2 with the corresponding defined range, works great except the code below does not allow for combobox1 to be blank or have a nonmatching value.
I'm looking to achieve two things.
Have combobox1 with no value have the same result in combobox2 no value .
Have combobox1 to have a value without a corresponding defined range then leave combobox2 blank.
In the current state if either of the two occur the code fails.
Thank you in advance for any help or assistance.
I have one combo box supplying the row source to another combo box. I am using define range in the first combo box to achieve this. Everything is working well except for when combobox1 is blank or does not have a matching named range.
Combo box 1 has a row source of sheet1!A2:A33. the data in the Cells sheet1!A2:A33 has a range match for each of the 31 line items.
When I select an item and combobox1 it supplies combobox2 with the corresponding defined range, works great except the code below does not allow for combobox1 to be blank or have a nonmatching value.
I'm looking to achieve two things.
Have combobox1 with no value have the same result in combobox2 no value .
Have combobox1 to have a value without a corresponding defined range then leave combobox2 blank.
In the current state if either of the two occur the code fails.
Thank you in advance for any help or assistance.
Code:
Private Sub ComboBox1_Change()
Me.ComboBox2.Value = ""
Me.ComboBox2.RowSource = Me.ComboBox1.Value
If Me.ComboBox1.Value = "" Then
Exit Sub
End If
End Sub