ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populate multi-column list in worksheet not in a UserForm (https://www.excelbanter.com/excel-programming/412499-populate-multi-column-list-worksheet-not-userform.html)

Afzal

Populate multi-column list in worksheet not in a UserForm
 
I have simple list box on the sheet of an Excel (not on a userForm).
I want to add two column of information. I set the multi-column value to 2.
How can I add values to 2nd column?

Adding values to first column works fine such as:
lstTest.list = array("a","b","c")

but, adding value to second column doesn't work:
lstTest.list(0,1) = array("a","b","c")

And, I noticed that RowSource property is not there either, any one know why?

Thanks,
Afzal

Bernie Deitrick

Populate multi-column list in worksheet not in a UserForm
 
Dim myArr(1 To 3, 1 To 2)

myArr(1, 1) = "a1"
myArr(1, 2) = "a2"
myArr(2, 1) = "b1"
myArr(2, 2) = "b2"
myArr(3, 1) = "c1"
myArr(3, 2) = "c2"

lstTest.List = myArr

HTH,
Bernie
MS Excel MVP


"Afzal" wrote in message
...
I have simple list box on the sheet of an Excel (not on a userForm).
I want to add two column of information. I set the multi-column value to 2.
How can I add values to 2nd column?

Adding values to first column works fine such as:
lstTest.list = array("a","b","c")

but, adding value to second column doesn't work:
lstTest.list(0,1) = array("a","b","c")

And, I noticed that RowSource property is not there either, any one know why?

Thanks,
Afzal




Afzal

Populate multi-column list in worksheet not in a UserForm
 
Thanks Deitrick.
I found out why the other columns weren't showing.
I had placed 1 pt, 1 pt in ColumnWidths property assuming inches or cm to be
the default unit of measurement but it turns out 72 pt;72 pt is equivalent to
an inch.

"Bernie Deitrick" wrote:

Dim myArr(1 To 3, 1 To 2)

myArr(1, 1) = "a1"
myArr(1, 2) = "a2"
myArr(2, 1) = "b1"
myArr(2, 2) = "b2"
myArr(3, 1) = "c1"
myArr(3, 2) = "c2"

lstTest.List = myArr

HTH,
Bernie
MS Excel MVP


"Afzal" wrote in message
...
I have simple list box on the sheet of an Excel (not on a userForm).
I want to add two column of information. I set the multi-column value to 2.
How can I add values to 2nd column?

Adding values to first column works fine such as:
lstTest.list = array("a","b","c")

but, adding value to second column doesn't work:
lstTest.list(0,1) = array("a","b","c")

And, I noticed that RowSource property is not there either, any one know why?

Thanks,
Afzal






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

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