ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Collections problem (https://www.excelbanter.com/excel-programming/364983-re-collections-problem.html)

RB Smissaert

Collections problem
 
How about simply:

If bCondition1 = True Then
Dim coll1 as Collection
Set coll1 = New Collection
End If

If bCondition2 = True Then
Dim coll2 as Collection
Set coll2 = New Collection
End If

etc.

RBS


"John" wrote in message
...
Hi there,

I'm trying to create a variable number (between 1 and 4) of collections,
but I don't know what that number will be in advance. Is there a way of
creating (and declaring) collections at runtime?

So far my solution has been to declare four collections at the beginning
of the code ie

Dim col1 As New Collection
Dim col2 .....

and then setting the unwanted ones to Nothing once the requirement can be
counted, however this seems a bit wasteful.

Any guidance?

Best regards

John



John[_88_]

Collections problem
 
Hi RB,

Yes that would work too. I wasn't aware of the early binding problem, so
will use this, thanks.

Best regards

John

"RB Smissaert" wrote in message
...
How about simply:

If bCondition1 = True Then
Dim coll1 as Collection
Set coll1 = New Collection
End If

If bCondition2 = True Then
Dim coll2 as Collection
Set coll2 = New Collection
End If

etc.

RBS


"John" wrote in message
...
Hi there,

I'm trying to create a variable number (between 1 and 4) of collections,
but I don't know what that number will be in advance. Is there a way of
creating (and declaring) collections at runtime?

So far my solution has been to declare four collections at the beginning
of the code ie

Dim col1 As New Collection
Dim col2 .....

and then setting the unwanted ones to Nothing once the requirement can be
counted, however this seems a bit wasteful.

Any guidance?

Best regards

John






All times are GMT +1. The time now is 01:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com