![]() |
collection usage/syntax please
What is the proper syntax for the collection statements in the
following pseudo code: Dim C as Collection Loop over cells in a range: C = New Collection [or is it Set C =.....] LoadC ( C , cell from Loop)[will add item to collection] UseC (C) [will use or do something with the collection] C = Nothing [is this proper, all examples use a Remove] Next Loop over cells Thanks. |
collection usage/syntax please
Dim colTest As Collection
Dim i As Long Set colTest = New Collection For i = 1 To 10 colTest.Add "Key" & i, "Item" & i Debug.Print colTest.Item(i) Next i Set colTest = Nothing -- HTH Bob Phillips "dick" wrote in message oups.com... What is the proper syntax for the collection statements in the following pseudo code: Dim C as Collection Loop over cells in a range: C = New Collection [or is it Set C =.....] LoadC ( C , cell from Loop)[will add item to collection] UseC (C) [will use or do something with the collection] C = Nothing [is this proper, all examples use a Remove] Next Loop over cells Thanks. |
collection usage/syntax please
THANKS!!
|
collection usage/syntax please
Although Bob's code will work as written, it is confusing in that
he has the order of Key and Item reversed. Item is the first argument, Key is the second (optional) argument in the Add method. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Bob Phillips" wrote in message ... Dim colTest As Collection Dim i As Long Set colTest = New Collection For i = 1 To 10 colTest.Add "Key" & i, "Item" & i Debug.Print colTest.Item(i) Next i Set colTest = Nothing -- HTH Bob Phillips "dick" wrote in message oups.com... What is the proper syntax for the collection statements in the following pseudo code: Dim C as Collection Loop over cells in a range: C = New Collection [or is it Set C =.....] LoadC ( C , cell from Loop)[will add item to collection] UseC (C) [will use or do something with the collection] C = Nothing [is this proper, all examples use a Remove] Next Loop over cells Thanks. |
All times are GMT +1. The time now is 03:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com