Listbox to Array

J

J Streger

I was looking for a faster way to get all the values in a listbox. I have
this code:

Dim vArray As Variant
dim strCSV as String

vArray = Lbox.List

strCSV = Join(vArray, ",")

but it returns a two dimentional array of (n, 9) bounds, with nulls in the
1-9 entries of every array, which can't be used in Join. The listbox has only
1 column in the properties. Is there anyway to get a one dimentional array
from a listbox? The listbox is programatically filled so it is not getting
it's source from a worksheet range. Thanks.

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003
 
J

Jim Rech

How about:

vArray = Application.Transpose(ListBox1.List)

--
Jim
|I was looking for a faster way to get all the values in a listbox. I have
| this code:
|
| Dim vArray As Variant
| dim strCSV as String
|
| vArray = Lbox.List
|
| strCSV = Join(vArray, ",")
|
| but it returns a two dimentional array of (n, 9) bounds, with nulls in the
| 1-9 entries of every array, which can't be used in Join. The listbox has
only
| 1 column in the properties. Is there anyway to get a one dimentional array
| from a listbox? The listbox is programatically filled so it is not getting
| it's source from a worksheet range. Thanks.
|
| --
| *********************
| J Streger
| MS Office Master 2000 ed.
| MS Project White Belt 2003
|
| User of MS Office 2003
|
 
J

J Streger

I keep getting a type mismatch error when trying to use that function.

Surprisingly it is not in Intellisense, but Excel seems to function when I
pass a blank array through it. I've never seen that function before now.
--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top