> You should really be using the Option Explicit statement . . . Try adding that
> statement in the (General)(Declarations) section of the code window and
> see if that solves your problem. . . .
> Rick
It was a mistake (inadequate testing) on my part. You'd need to add the
Redim'd array back into the Collection are remove the original element. All
said and done, it is likely all overkill simply to For Each on a set of
arrays.
Dim Coll As New Collection
Sub AAA()
Set Coll = Nothing ' clear out the collection
Dim V As Variant
Dim N As Long
Dim Arr1() As Long ' declare some dynamic arrays
Dim Arr2() As Long
Dim Arr3() As Long
Coll.Add Arr1 ' add them to the collection
Coll.Add Arr2
Coll.Add Arr3
For N = 1 To Coll.Count
V = Coll(N)
ReDim V(1 To 3) ' redim each array 1 to 3
V(1) = N * 10 ' enter some easiliy identiful values
V(2) = N * 100
V(3) = N * 1000
Coll.Add V, before:=N ' insert newly redim'd array back to
collection
Coll.Remove N + 1 ' remove original array
Next N
''''''''''''''''''''''''''''''''''
' Confirmation of correct results.
''''''''''''''''''''''''''''''''''
For N = 1 To Coll.Count
V = Coll(N)
Debug.Print "================="
Debug.Print "ARRAY: " & N, " ALLOCATED: " & IsArrayAllocated(V)
Debug.Print "VALUES OF ELEMENTS:"
Debug.Print V(1), V(2), V(3)
Next N
End Sub
Function IsArrayAllocated(A As Variant) As Boolean
'''''''''''''''''''''''''''''''''''''''''''''''''''''
' Ensure that a dynamic array is actually allocated.
'''''''''''''''''''''''''''''''''''''''''''''''''''''
On Error Resume Next
IsArrayAllocated = Not IsError(LBound(A)) And LBound(A) <= UBound(A)
End Function
And don't get started on the old "Ranges As Arrays" bit. Ranges are not
arrays.

Signature
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
"Alan Beban" <unavailable@no.com> wrote in message news:emc%
23Vj3LIHA.4880@TK2MSFTNGP03.phx.gbl...
>> You should really be using the Option Explicit statement . . . Try adding
>> that statement in the (General)(Declarations) section of the code window
[quoted text clipped - 24 lines]
> Debug.print UBound(Arr1) '<-------Error message
>>>> End Sub
Alan Beban - 25 Nov 2007 19:09 GMT
> And don't get started on the old "Ranges As Arrays" bit. Ranges are not
> arrays.
No, no. You somehow got it in your mind that I disagree with you on
that; I don't! I mentioned before about how irritating it was to me
(many years ago)) that IsArray(iVar) returned True when iVar was not an
array, but a range. But because it does, it is often necessary to
provide code to confirm that one is dealing with a true array and not a
multi-cell range that IsArray treats as an array.
(You may be thinking of my erstwhile suggestion that Ranges are
Collections, which you find almost as attractive as the idea that ranges
are arrays :-))
Regards,
Alan