-1

I am trying to create a jagged array with an array of Double() arrays. I am simply trying to add this a() Double into d() dynamically. The error comes when I try to pull one of the copies of a from d, and put it into x.

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
1
  • It is working now when I ReDim x(1 to 10, 1 to 3). Or when I used the size of d(1). Is there a way to do it without sizing x first? Commented May 4, 2014 at 1:28

1 Answer 1

1

Try this. Change Array(a) to a.

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) = a
 Next i


 Dim x() As Double
 x = d(1)   ' Error, Type Mismatch

 MsgBox (x(1, 2))

End Sub
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.