Populating multi-column listbox from collection?

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)


0
What
9/9/2004 1:19:00 AM
excel 39879 articles. 2 followers. Follow

1 Replies
386 Views

Similar Articles

[PageSpeed] 29

Was given the answer on excel. programming (Yeah - I know - please don't
double post!)
If anyone cares , here is the solution:
--------------------------------------------------------

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.

-- 
Regards,
Tom Ogilvy




-- 

/ Sean the Mc /


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

"What-a-Tool" <Die!FrigginSpammersDieDie!@IHateSpam.Net> wrote in message
news:6cO%c.7113$OZ6.136@okepread06...
> 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)
>
>


0
What
9/10/2004 11:02:42 AM
Reply:

Similar Artilces:

Help with Populating StringMap table
I have a user request that I'm sure is made with some frequency, so I'd like to see if anyone lse has solved a similar probelm, and/or if my solution might work. My users requested that we replace the State/Province text box with a State drop-down list. Since this textbox appears in several places, and since the tools for populating and maintaining picklist are poor (to be generous), I decided to look into automating the process. I created a stagin database for just such things, with a mirror stringmap table. Through a query, I can populate the CRM stringmap table quite easily, with ...

any way to open multi html fiels in differen ie7 tabs from batch file?
I managed to open in single tab with last file shown while the others in history I also managed to get multi instance of ie7 I also can open one at a time but wait for ie7 to close I search the web, no luck so far. the Firefox way is definitely not supported. help would be much appreciated. platform ie7 on vista 64 "GS" <gsmsnews.microsoft.comGS@msnews.Nomail.com> wrote in message news:OQtrdi43KHA.348@TK2MSFTNGP04.phx.gbl... > I managed to open in single tab with last file shown while the others in > history > I also managed to get multi...

Counting text in a column
I used to think I was good at Excel until this stumped me. I have a column with a variety of text in each cell. Example: A1 bob bob ted ted ted charley charley charley charley, etc. Is there a formula or way I can take the whole column of data and hav it come back with something similar to: bob = 2 ted=3 charley=4 etc. for all the variables in the column? Please help, I am dying over here -- prom4 ----------------------------------------------------------------------- prom4x's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2901 View this thread: http://www...

Do a two way lookup and get the result in multiple columns
Hi, I have a worksheet with data on store sales: StoreLoc Date Sales$ A 10/28/2005 $100 A 11/04/2005 $150 B 10/28/2005 $200 B 11/04/2005 $250 B 11/11/2005 $300 B 11/18/2005 $350 C 11/04/2005 $300 C 11/11/2005 $350 C 11/18/2005 $400 D 11/11/2005 $400 etc. I wanted to do a two-way lookup on StoreLoc and Date and get the sal...

Subtotals by Column
Hi, Need a support in: Making subtotals by column not by row. Usually when I go Data-->Subtotals.., It offers me: At each change in.. and then a series of column names. Well I need to do it the other way.It's like traspose the outline. I've seen it on a file but do not know how to do it. Please any help is welcome -- Edgar Rey Hi, Did you tried Subtotal(). "Edgar" wrote: > Hi, Need a support in: > Making subtotals by column not by row. Usually when I go Data-->Subtotals.., > It offers me: At each change in.. and then a series of column nam...

Strange error message when loading a collection with an item of user defined type
Hi, I want to store an unknown number of records, read from a txt data, into a Collection. Each record is made of 26 strings, so I defined a user-defined type Record: Const NLines As Long = 26 Type Record Lines(NLines) As String End Type Dim MyRecord As Record I also defined a Collection object to store all the record: Dim List As Collection Set List = New Collection However, when I read a record and then try to load it into List: Data.Add Item:=MyRecord I get this incomprehensible (for me) error message: "Only public user defined types defined in publ...

A formula that only shows the number of ex: "A" in a column and
Hi! Can i make a formula that only shows the number of ex: "A" in a column and ignore any hidden rows that result from filtering. Maybe i ca combine =SUBTOTAL(3;P:P) and =COUNTIF($P:$P;"=A") in some way? Regards Gunnar Gunnar, You basically need to reproduce your filtering: =SUMPRODUCT((P1:P10="A")*(B1:B10="B")*(C1:C10="C")*1) HTH, Bernie MS Excel MVP "Gunnar Sandstr�m" <gunnar.sandstrom@ericsson.com> wrote in message news:c9n09c$hh2$1@newstree.wise.edt.ericsson.se... > Hi! > Can i make a formula that only shows ...

Sum From Beginning of Column #2
How do I create a formula that adds from the top of a column? Here's the situation. I have a column of numbers (with a header of "Pay"). To the right of that colum I want to keep a running total ("Yearly Total"). Every time I get paid, I'm going to enter the amount in the pay column and then I want the Yearly Total column to automatically add it. When I create a fomula (say =SUM(B2:B21)), and propigate it down, it doesn't start at the top. In others words the next formula is =SUM(B3:B22). I want it to be =SUM(B2:B22). And, if a value is not filled in on t...

Removing in column B when listed in Column A
Hi I have a list of text in column A aaaa bbbb ccccc dddd eeee ffff etc.... I also have a list in column B zzzz ccccc xxxx aaaa ffff gggg etc What I need to do is remove all the entries in colum a from column B In the example above I would have in column B left zzzz xxxx gggg Hope this makes sence and someone can help. Thanks Iai -- Message posted from http://www.ExcelForum.com Iain, I assume your colums A en B are filled with values A1:A10 and B1:B10 Put in C1 the formula : If(ISNA(VLOOKUP(B1,$A$1:$A$10,1,0)),0,1) and copy down to C10. Copy and paste special / values column...

Hide column in ListView
I have an asp.net web page with a databound ListView showing in Grid format. I would like to conditionally hide a column in the ListView based on a checkbox outside of the ListView. I have a ItemDatabound event and thought the ListViewItemType could be checked but it only has data, insert and blank properties. The checkbox is called ckHasOT and I was planning to check something like If ckHasOT.Checked = False Then .... I would like to hide the column from all Templates (Item, Edit and Insert). Thanks. -- David "DavidC" <dlchase@lifetimeinc.com> wrote...

Switch row with column?
Hello guys, im very new to excel, and im trying to learn. I cant seem to figure out how to switch my chart around. I have a list of companies on the top, and down the left i have a list of locations. How can i make the locations go on top, and the companies down the left? -- jason57gizmo ------------------------------------------------------------------------ jason57gizmo's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=30700 View this thread: http://www.excelforum.com/showthread.php?threadid=503627 Depending on the number of rows you're using--since t...

How can I NOT include relationship columns in child nodes?
I am trying to create an XML file with nested 'child' data. I have multiple columns that comprise the data relation(s). How can I NOT include the related columns in the child nodes? Code below (should be able to cut, paste, and run directly). ------------------------------------------------------------------------------ -------- 'Instantiate a new dataset. Dim MyTrx As New DataSet 'Name the dataset. MyTrx.DataSetName = "OUTPUT" 'Add a transaction table. Dim dtTransaction As New DataTable &...

How to detect event in scrollbar of a ListBox
This is a multi-part message in MIME format. ------=_NextPart_000_0029_01C772C0.DC9EA420 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Maybe I just need a little hint to do this! As long as a scrollbar of a listbox is embedded within, I don't see what to do, to detect the click on the scrollbar instead of items... jmarc... ------=_NextPart_000_0029_01C772C0.DC9EA420 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional...

Export empty columns to Excel
I have a database, and some data in that needs to be imported into another database through Excel. I have no control over this, that's the way it needs to be. These Excel files have certain columns, and not all of them relevant for my database. Can I make a query with the relevant fields from my database, and have the needed columns inserted where appropriate? Also, some of my relevant fields have different names than the Excel template. Can I change the column headings in my query to match the Excel template? For example if you have to export and leave columns 2 and 3 blank an...

(2nd attempt)How to create CMainFrame-based dialog to display variable number of listboxes in a CFormView
Hello, I have an app where I need to display a variable number of CListBoxes (in a single row) in a CFormView. I don't know how to dynamically create the CListBoxes and attach them to the CFormView, something that would normally be done through resources if it were a fixed number of listboxes.. Could anyone give me an idea of how to dynamically allocate and attach controls and then any cleanup? I also need to know how to manually hook up a CMainFrame with a CFormView, as the AppWizard only creates something like that as a topmost window, I think. Any help would be greatly appreciate...

Calculating percent of times a value is in a column and total #
Ok so I have a column with values in it. Say A4:A12, the values entered will always be 1, 2, 3, or 4. I need a formula that will calculate the % that say a 1 appears in that range and I need a formula that will calculate the total number of 1s in that range. Thanks! =countif(a4:a12,1)/count(a4:a12) Format as percent Regards, Fred "clbritt76" <clbritt76@discussions.microsoft.com> wrote in message news:28AFAD8A-88BC-4151-AE7F-5463AA6E9B68@microsoft.com... > Ok so I have a column with values in it. Say A4:A12, the values entered > will > alwa...

large numbers not losing the end without formatting column
Hi, i need to be able to open a .csv file in Excel with large numbers and or Leading zeros without having to put a ' single quote in or format the column as text or import using text to columns so that i do not lose the actual/original data i am passing to Excel - is there anyway to do this or fool Excel in the .csv file into thinking the number field is a text field - i have tried inserting a row at the begininng with only text in each column but Excell still looses leading zeros and chops the ends of the numbers? thanks best regards kevin The problem is that Excel thinks it knows ...

multi-line cells
Hi, I need to be able to put some multi-line data into single cells in an excel spreadsheed. In particular, I want to put in the full address of clients without putting the address parts in a group of cells. I want to be able to write the address just as I would on an envelope. I can't seem to get excell to take the carriage return character in a single cell's input. Can anyone help? Thanks in advance, Steve Steve, press ALT-ENTER to put in a line break. Bob Flanagan Macro Systems http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel &quo...

Inbox Columns company
Hi ! I tried to add the column company from contacts to my inbox but the field stays blank. What Iam doing wrong ? Thanks for your help Thomas Radas Any folder view shows only the data in that folder, even though Outlook = lets you think otherwise by allowing you to add fields from different = types of items in the folder. The Company field that you see under All = Contacts Field does not apply to messages.=20 --=20 Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for=20 Administrators, Power Users, and Developers http://www.outlookcode.com/jumpst...

Column name from recordset?
Is there a way to get the column name in access while using vba? For example I have a recordset that uses the valus reset1(1), etc. Can I figure out the name of the column it selected? "AJ" <AJ@discussions.microsoft.com> wrote in message news:91F8AF50-25FB-4D8E-9EBF-082D7FD7CF84@microsoft.com... > Is there a way to get the column name in access while using vba? For > example > I have a recordset that uses the valus reset1(1), etc. Can I figure out > the > name of the column it selected? So "reset1" is the name of the recordset? Each field in th...

Total width of multiple columns
Is there a quick way of finding out the total width of several adjacent columns? Hi, I'd be intrigued to understand why you need this but here's one way. Call with =Col_Width() Select a single row of cells and tap F9 to make it re-calculate Function Col_Width() As Variant Dim C As Range Application.Volatile If Selection.Rows.Count > 1 Then Exit Function For Each C In Selection Col_Width = Col_Width + C.ColumnWidth Next End Function -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while ...

Return column number of matching cell in external range
Cell A1 in open_workbook_1 contains a text string. The same text string will be found somewhere in closed_workbook_1 within the cell range A1:Z100 How can I return to cell A2 in open_workbook_1, the column number of the cell in closed_workbook_2 which contains the text string? Thanks. Nazg�l wrote: > Cell A1 in open_workbook_1 contains a text string. > > The same text string will be found somewhere in closed_workbook_1 > within the cell range A1:Z100 > > How can I return to cell A2 in open_workbook_1, the column number of > the cell in closed_workbook_2 which contain...

Reading multi-part MIME encoded emails in OUTLOOK 2003
Broadcast-type emails to employees relayed from an exchange server show in my Outlook with the header and all the raw encoding info for the message format included in the body of the message. If the message includes an incorporated attachment that attachment is displayed in what looks like uuencoded form in the middle of the format coding info. I have only had this problem since I installed Outlook 2003 on a new machine running Vista, although in searching for info on this problem I found similar threads in 2004 and 2005 under XP. None of those threads led to resolution of the problem...

merge columns
Greetings. I have data in Column B (same text in each field) that I want to add to all of the fields in Column A (different text in each field) I have tried merge & center and tried to work out how to do a CONCATENATE but am totally stuck. Is there any way to add the sentence in Col B to the end of the text in Col A without cutting and pasting on every line?? Tell me there is an easy way to do this!! If its a formula I need to use - where on earth do you write it?? Many thanks in advance =A1&B1 (as a formula in cell C1, for example) will do your concatenation (or =A1&&quo...

How to remove a wildcard character from text column?
How does one remove a wildcard character from a text string? In this case the text contains an asterisk followed by a slash. */ If you're talking about "Edit - Replace", Precede the asterisk with the tilde ( ~* ) in the "FindWhat" box. -- HTH, RD ============================================== Please keep all correspondence within the Group, so all may benefit! ============================================== "Stace Cameron" <scameron@siumed.edu> wrote in message news:%23oWuV4WrEHA.3396@tk2msftngp13.phx.gbl... How does one remove a wildcard character f...