ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   2 combo boxes (https://www.excelbanter.com/excel-worksheet-functions/12179-2-combo-boxes.html)

Greg

2 combo boxes
 
I have 2 combo boxes and depending on the choice in combo 1 I want combo 2
box to change choices. Is this possible. thx, greg

IC

Using VBA you can specify the ListFillRange for ComboBox2.

Private Sub ComboBox1_LostFocus()
If ComboBox1.Value = "Option1" Then
ComboBox2.ListFillRange = "B1:B3"
ElseIf ComboBox1.Value = "Option2" Then
ComboBox2.ListFillRange = "C1:C3"
ElseIf ComboBox1.Value = "Option3" Then
ComboBox2.ListFillRange = "D1:D3"
End If
End Sub

You can also clear the CB2 displayed entry when selecting CB1 with this

Private Sub ComboBox1_GotFocus()
ComboBox2.Value = ""
End Sub

otherwise CB2 continues to display the last selected item until you change
it.

Ian

"Greg" wrote in message
...
I have 2 combo boxes and depending on the choice in combo 1 I want combo 2
box to change choices. Is this possible. thx, greg





All times are GMT +1. The time now is 11:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com