Linked comboboxes - select either one

Nogslaw

Well-known Member
Joined
Jul 9, 2004
Messages
904
I have 2 columns in sheet 1. Column A contains associate names, and column B contains their ID#'s. I have a userform with 2 comboboxes, one for names and one for ID's. I would like to be able to select either box and have the other autoselect the corresponding information. Currently, I have it working if I select something out of the first box by using a vlookup command. However, I cannot figure out how to do the 2nd box. I have tried a match function, but couldn't get it to work consistently.
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Say you have 2 lists name List1 and List2, being the RowSource property for ComboBox1 and ComboBox2 respectively. Then you can use this code:

Code:
Dim Disabled As Boolean

Private Sub ComboBox1_Change()
    If Disabled Then Exit Sub
    Disabled = True
    ComboBox2.Value = Range("List2").Cells(ComboBox1.ListIndex + 1, 1)
    Disabled = False
End Sub

Private Sub ComboBox2_Change()
    If Disabled Then Exit Sub
    Disabled = True
    ComboBox1.Value = Range("List1").Cells(ComboBox2.ListIndex + 1, 1)
    Disabled = False
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,118,436
Messages
5,572,107
Members
412,441
Latest member
kelethymos
Top