ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding items to the second column of a list box (https://www.excelbanter.com/excel-programming/283487-adding-items-second-column-list-box.html)

mika

Adding items to the second column of a list box
 
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

Tom Ogilvy

Adding items to the second column of a list box
 
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?

--
Regards,
Tom Ogilvy

"mika" wrote in message
...
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




mika

Adding items to the second column of a list box
 
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
-----Original Message-----
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?

--
Regards,
Tom Ogilvy

"mika" wrote in

message
...
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



.


Dave Peterson[_3_]

Adding items to the second column of a list box
 
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

mika wrote:

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
-----Original Message-----
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?

--
Regards,
Tom Ogilvy

"mika" wrote in

message
...
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



.


--

Dave Peterson



All times are GMT +1. The time now is 04:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com