Adding items to the second column of a list box

  • Thread starter Thread starter mika
  • Start date Start date
M

mika

Hi,

I have a 2-column list box, but I can't figure out how to
add items to the second column. Any help would be greatly
appreciated.

Thanks,
Mika
 
if you are using the rowsource or listfillrange, just set the reference to
two columns

Sheet1!A1:B20

Also, set the columncount property to 2

if not, how are you populating the listbox?
 
Hi,

I am populating from a one dimensional array.

I have two one dimensional arrays, so I want to populate
the first column with values from the 1st array, and the
second coumn with values from the 2nd array.

Thanks,
mika
 
One way:

Private Sub UserForm1_Initialize()

Dim myArr1 As Variant
Dim myArr2 As Variant
Dim iCtr As Long

myArr1 = Array("a", "b", "c", "d")
myArr2 = Array("1", "2", "3", "4")

With Me.ListBox1
.ColumnCount = 2
For iCtr = LBound(myArr1) To UBound(myArr1)
.AddItem CStr(myArr1(iCtr))
.List(.ListCount - 1, 1) = myArr2(iCtr)
Next iCtr
End With

End Sub
 
Back
Top