I am trying to add an array to an array of Double arrays in a for loop. Here is the code I have:
Sub Test3()
Dim a() As Double, i As Integer
ReDim a(1 To 10, 1 To 3)
Dim d
For i = 1 To 3
d = Array(a)
Next i
End Sub
In this test I'm just trying to add 3 copies of 'a' into 'd'. I have d = Array(a) which of course doesn't work, but I don't know what line to replace it with
Edited code for clarity
New Code Attempt:
Sub Test3()
Dim a() As Double, i As Integer
ReDim a(1 To 10, 1 To 3)
a(1, 2) = 3.5
Dim d() As Variant
For i = 1 To 3
ReDim Preserve d(1 To i)
d(i) = Array(a)
Next i
Dim x() As Double
x = d(1) ' Error, Type Mismatch
MsgBox (x(1, 2))
End Sub
I get the error of a type mismatch on x = d(1)
You want what's called a "Jagged Array", or Array of Arrays
Try this