I have an array of arrays (not a 2D array) in EXCEL VBA and I need to add elements to the inner arrays. e.g.:
Option Explicit
Sub ArrayofArrays()
Dim OuterArray() As Variant
ReDim OuterArray(0 To 0)
Dim InnerArray() As Variant
ReDim InnerArray(0 To 0)
InnerArray(0) = "Foo"
OuterArray(0) = InnerArray
ReDim Preserve OuterArray(LBound(OuterArray) To UBound(OuterArray) + 1)
End Sub
I could now access the inner element by:
debug.print OuterArray(0)(0)
which prints me "Foo"
But how can I extend the array inside OuterArray?
The last line only adds an empty element to the OuterArray:
ReDim Preserve OuterArray(LBound(OuterArray) To UBound(OuterArray) + 1)
But what I want is this:
¦___OuterArray(0)
¦_____________OuterArray(0)(0): "Foo"
¦_____________OuterArray(0)(1): "Bar"
Thanks!
InnerArray?