Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ck ck is offline
external usenet poster
 
Posts: 52
Default Number of objects in a collection

Hi,

Does anyone know the maximun number of objects a collection variable can
hold (in Excel 2003 and 2007)? I tested it in Excel 2003 and it seems to me
that there is an upper limit of 256 objects per collection variable but I
still want to confirm.

Cheers.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Number of objects in a collection

I ran this in xl2003:

Option Explicit
Sub testme()
Dim myColl As Collection
Dim iCtr As Long

Set myColl = New Collection
For iCtr = 1 To 1000000
myColl.Add Item:="A" & Format(iCtr, "000000")
Next iCtr

Debug.Print myColl.Count

End Sub

And got:
1000000
in the immediate window


CK wrote:

Hi,

Does anyone know the maximun number of objects a collection variable can
hold (in Excel 2003 and 2007)? I tested it in Excel 2003 and it seems to me
that there is an upper limit of 256 objects per collection variable but I
still want to confirm.

Cheers.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Number of objects in a collection

On Sun, 13 Apr 2008 19:29:24 -0500, Dave Peterson
wrote:

I ran this in xl2003:

Option Explicit
Sub testme()
Dim myColl As Collection
Dim iCtr As Long

Set myColl = New Collection
For iCtr = 1 To 1000000
myColl.Add Item:="A" & Format(iCtr, "000000")
Next iCtr

Debug.Print myColl.Count

End Sub

And got:
1000000
in the immediate window


Interesting.

I ran this in Excel 2007 and got the same result.

But when I "Watch" myColl, only items 1 to 256 are displayed in the Watches
window.

However, the other items are there, as evidenced by this in the immediate
window (with the macro stopped and End Sub):


?mycoll(256)
A000256
?mycoll(257)
A000257
?mycoll(1234)
A001234
?mycoll(123456)
A123456
?mycoll(999999)
A999999
?mycoll(1000000)
A1000000

--ron
  #4   Report Post  
Posted to microsoft.public.excel.programming
ck ck is offline
external usenet poster
 
Posts: 52
Default Number of objects in a collection

Interesting. I didn't use the count method but I dragged the collection
variable in the watches window instead.

For some reasons, only 256 items of the collection variable are shown in the
watches window.

"Dave Peterson" wrote:

I ran this in xl2003:

Option Explicit
Sub testme()
Dim myColl As Collection
Dim iCtr As Long

Set myColl = New Collection
For iCtr = 1 To 1000000
myColl.Add Item:="A" & Format(iCtr, "000000")
Next iCtr

Debug.Print myColl.Count

End Sub

And got:
1000000
in the immediate window


CK wrote:

Hi,

Does anyone know the maximun number of objects a collection variable can
hold (in Excel 2003 and 2007)? I tested it in Excel 2003 and it seems to me
that there is an upper limit of 256 objects per collection variable but I
still want to confirm.

Cheers.


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Number of objects in a collection

I wasn't smart enough to look in the watch window--but Ron was.

I don't have any idea why collections are treated like this.

CK wrote:

Interesting. I didn't use the count method but I dragged the collection
variable in the watches window instead.

For some reasons, only 256 items of the collection variable are shown in the
watches window.

"Dave Peterson" wrote:

I ran this in xl2003:

Option Explicit
Sub testme()
Dim myColl As Collection
Dim iCtr As Long

Set myColl = New Collection
For iCtr = 1 To 1000000
myColl.Add Item:="A" & Format(iCtr, "000000")
Next iCtr

Debug.Print myColl.Count

End Sub

And got:
1000000
in the immediate window


CK wrote:

Hi,

Does anyone know the maximun number of objects a collection variable can
hold (in Excel 2003 and 2007)? I tested it in Excel 2003 and it seems to me
that there is an upper limit of 256 objects per collection variable but I
still want to confirm.

Cheers.


--

Dave Peterson


--

Dave Peterson
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
series objects; finding specific ones in the collection cate Charts and Charting in Excel 2 April 4th 10 03:25 PM
Array of collection of match objects from RegExp fybar[_3_] Excel Programming 1 April 3rd 08 01:20 PM
Passing Objects from Excel VBA collection to a VB6 DLL Dan[_50_] Excel Programming 6 February 15th 06 10:34 PM
Range objects in a collection Corey B Excel Programming 2 September 25th 04 06:24 PM
Iterate over Collection Objects in Container. Bob Kilmer Excel Programming 1 August 28th 03 02:37 AM


All times are GMT +1. The time now is 08:52 PM.

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"