tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
Following from this thread:
I was told this piece of information:
Rich (BB code):
https://www.mrexcel.com/forum/excel-questions/1114405-collections.html
I was told this piece of information:
Rich (BB code):
Syntax
...
For Each element In group
...
element ... For collections, element can only be a Variant variable, a generic object variable, or any specific object variable.
So here's my code:
but it generates an object required error.
According to the article, i can be a Variant, generic object or specific object, so I have declared it here as a Collection (ie a specific object), yet it stil fails.
Why is that?
I've even tried:
but get the same error.
Thanks
<strike></strike>
<strike></strike><strike></strike>
Rich (BB code):
Dim Coll As Collection
Set Coll = New Collection
Coll.Add "Apple"
Coll.Add "Pear"
Coll.Add "Orange"
Dim i As Collection
For Each i In Coll
Debug.Print i
Next i
but it generates an object required error.
According to the article, i can be a Variant, generic object or specific object, so I have declared it here as a Collection (ie a specific object), yet it stil fails.
Why is that?
I've even tried:
Rich (BB code):
Dim Coll As Collection
Set Coll = New Collection
Coll.Add "Apple"
Coll.Add "Pear"
Coll.Add "Orange"
Dim i As Collection
Set i = New Collection
For Each i In Coll
Debug.Print i
Next i
but get the same error.
Thanks
<strike></strike>
<strike></strike><strike></strike>
Last edited: