(Solved) – VBA adding an array to another array


I’m super new to VBA (and stack overflow, this is my first post) and I’m trying to simplify my code, but I just cannot seem to find a way to add an 1D array to 3D array in 1 line.
I have 3 dimensional array

Dim myArray(50, 20, 3) As Variant

Currently I have to do this:

myArray(0, 0, 0) = 0: myArray(0, 0, 1) = 1: myArray(0, 0, 2) = 2

You can see how I have actually 3 statements in 1 line and I had to type the array name 3 times.
What I would instead like to do is something like this:

myArray(0, 0) = {0,1,2}

End result should be the same.

Leave a Reply

Your email address will not be published. Required fields are marked *