MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Combo Box Matching text

Posted by Lucky on December 07, 2001 7:18 AM

I am trying to tell a combobox1 that if the text is "123" then change the text in combobox 2 to "abc" and vice versa. I achieved that with the following (the cell referenced is the start of each list)

Private Sub ComboBox2_Change()
If ComboBox2.Text = (ActiveSheet.Range("a1")) Then
ComboBox3.Text = (ActiveSheet.Range("b1"))
End If

Private Sub ComboBox3_Change()
If ComboBox3.Text = (ActiveSheet.Range("b1")) Then
ComboBox2.Text = (ActiveSheet.Range("a1"))
End If
Exit Sub

The lists are over one hundred cells long, and instead of repeating the above code a hundred times I was wondering if I could simply compare the ranges/lists.
It is ordered so that a1 matches with b1, a2=b2, c3=c3....etc

Hope this is clear!

Posted by Ivan F Moala on December 08, 2001 2:33 AM

Unsure exactly what is required ??
But will this do;

Private Sub ComboBox1_Change()
ComboBox2.ListIndex = ComboBox1.ListIndex
End Sub