Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default collection usage/syntax please

THANKS!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sumproduct usage? Destrachan Excel Worksheet Functions 5 December 24th 09 11:59 AM
SUMPRODUCT usage wild turkey no9 Excel Worksheet Functions 5 April 25th 09 10:30 AM
100% cpu usage bill Excel Discussion (Misc queries) 1 March 2nd 06 10:27 AM
SQL - TOP 1 Usage ell[_2_] Excel Programming 6 August 26th 04 12:08 AM
Correct Syntax - Collection Key Paul Mac[_4_] Excel Programming 1 August 20th 04 01:21 AM


All times are GMT +1. The time now is 07:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"