Multiple Column ComboBox using Additem

  • Thread starter Thread starter Jimmi
  • Start date Start date
J

Jimmi

I all, I'm programming on a Mac, (Office X) and Everything was going
great until I ran into a little problem. Mac doesn't support the
RowSource property, so I must add Item. I've had sucess using a
combobox in a single column application, but not in multiple.

I have a sheet (codes) that contains 2 columns and (currently) 49
rows. The "A" column is the 2 didgit code and the "B" is the long
description. Upon change of the combobox, we fill in a textbox with
the code.

I can't get the combobox to fill to columns.

The code I have now:

For Each cell In Worksheets("Codes").[A2:A49]
ComboBox1.AddItem cell.Text
Next

As I said this works for single column but I need 2. Any help would be
greatly appriciated.
 
Jimmi,

You'll need to use a Listbox for multiple columns.

List boxes worked almost the same as a combobox.
 
Both of these worked for me (xl2002 on a wintel pc):

Option Explicit
Private Sub UserForm_Initialize2()

Dim myArr As Variant
myArr = Worksheets("sheet1").Range("a1:b10").Value

With Me.ComboBox1
.ColumnCount = 2
.List = myArr
End With

End Sub
Private Sub UserForm_Initialize()

Dim iRow As Long

With Me.ComboBox1
.ColumnCount = 2
For iRow = 1 To 10
.AddItem Worksheets("sheet1").Cells(iRow, "A")
.List(.ListCount - 1, 1) = Worksheets("sheet1").Cells(iRow, "B")
Next iRow
End With

End Sub

I all, I'm programming on a Mac, (Office X) and Everything was going
great until I ran into a little problem. Mac doesn't support the
RowSource property, so I must add Item. I've had sucess using a
combobox in a single column application, but not in multiple.

I have a sheet (codes) that contains 2 columns and (currently) 49
rows. The "A" column is the 2 didgit code and the "B" is the long
description. Upon change of the combobox, we fill in a textbox with
the code.

I can't get the combobox to fill to columns.

The code I have now:

For Each cell In Worksheets("Codes").[A2:A49]
ComboBox1.AddItem cell.Text
Next

As I said this works for single column but I need 2. Any help would be
greatly appriciated.
 
Back
Top