Filling 2 column list box with Collection?

W

What-a-Tool

Have a collection containing folders and files that I want to put into a 2
column list box using a For Loop.
I have done this in Access vba and .Net apps, but I'm going crazy trying to
get this to work in excel vba.
Can any one show or point me to a code sample demonstrating this, Please?

Found lots of samples of setting the list() property to an array, but
nothing on doing it row by row with a loop.

Thanks in advance for any help


--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
T

Tom Ogilvy

For Each Item In MyCollection
With UserForm1.ListBox1
.AddItem Item
.list(.listcount - 1, 1) = "filename"
End With
Next Item

You said a collection, but not sure where the pathes and the filenames are
located unless you are parsing them out of the collection or you have arrays
in the collection. In any event, how you address the listbox is
illustrated - you should be able to adapt it to your data source.
 
W

What-a-Tool

Thank you very much - was just the ~ .list(.listcount - 1, 1) = "filename"
~
That I wasn't seeing. Works great.

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 

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