I am writing a code that needs an array for each Element of the problem to be solved. The number of elements will be put by the user.

I need VBA to define a new array for each element from 1 to the number of elements. I am trying something like this:

[VBA]

Sub Assemble()

Dim i As Integer, j As Integer
Dim nElements As Integer, nNodes As Integer

For i = 1 To 3
Dim Ki(5) As Double
Next i

End Sub


[/VBA]

I would like this to define 3 arrays named K1, K2, K3 each of which has an Ubound of 5.

Excel is just defining 1 array called Ki 3 times when I use the above.

How can I do this right?

Thanks!