Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Robert Crandal wrote :
. My sample file shows how to do this. It uses a 2 col listbox w/Col2 as Boundcolumn. User only sees names in the list (sorted) because Col2 width is zero. Thanks so much for the demo. It is much appreciated. In looking at your code, it appears that you are populating the multi-column listbox with the following code: Me.ListBox1.list = vItemList Is "vItemList" a "Worksheet" type of variable that corrosponds to data on the worksheet? (I'm still kinda newbie with VBA, so I just wanted to verify) No. It's a VBA variant variable that I used to dump the original wks list into. I also dumped the temp wks list into it since the original data was no longer needed. One thing to note about filling arrays from a wks; the 1st element is 1 not zero, AND it's a 2D array (#Rows x #Cols) even if there's only 1 col. Also, is that the ONLY way to fill in a 2 column listbox, by passing a Worksheet/range to the ".list" property?? No. (I didn't pass a wks range to the listbox. I passed a 2D array to the listbox, which I populated from the temp wks) This is the quickest (and easiest) way to read/write a range. It also happens to be the quickest way to fill a listbox from an array. So then, there's 2 separate things happening: 1- range read/write, 2- populating a multi-col listbox with a multi-dim array. Note, though, that the array is dynamically sized as used here. This is preferred for unknown amounts of data. What if I have data that doesn't exist on the worksheet and I want to put that data into a 2 column, n-rows listbox?? For example, what if I have a mult-dim array of strings....can I use this data to fill in my multi-column listbox? Yes, in the same 'quick dump' fashion OR you can loop the array using AddItem and the List property (specifying row/col positions). The latter is slower by far. (Imagine a 10000 row by 20 col data table. Would you loop or dump?) So then, if you had such an array (10000,20) then you could set the listbox ColumnCount to the UBound of the 2nd dim and dump the data into it. -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
listbox problem | Excel Programming | |||
listbox problem #2 | Excel Programming | |||
listbox problem | Excel Programming | |||
Listbox Problem | Excel Programming | |||
ListBox problem | Excel Programming |