Can you please let me know how I can create a Two columns Look up combobox in Excel VBA UserForm? I am looking to create some thing like this:
I know we can add Items to combobox using a method like this:
Private Sub UserForm_Initialize()
With Me.ComboBox1
.AddItem "215"
.AddItem "316"
.AddItem "485"
End With
End Sub
but I need to generate a associated value with 215,316,485 and so on valyes like hammer,... Thanks for your time,
Fill a two-dimensional array and set the List
property of the ComboBox to that array:
Dim listEntries(3, 2) As Variant
listEntries(0, 0) = "215"
listEntries(0, 1) = "Hammer"
listEntries(1, 0) = "316"
listEntries(1, 1) = "Wrench"
listEntries(2, 0) = "485"
listEntries(2, 1) = "Pliers"
Me.ComboBox1.List = listEntries
You may also need to adjust the ColumnWidths
and TextColumn
properties accordingly
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.