Combining Arrays

  • I'm still feeling out how to use arrays in my VBA codes and I was hoping someone could help me out with this.

    I have two 2dimension arrays with the same count of rows but different columns. I was hoping there was a way to sum up all the rows of the two arrays into a 1 dimension/column array?

    Lets say:

    ReDim Array1 (1 to 11. 1 to 15)
    ReDim Array2 (1 to 11, 1 to 20)
    ReDim SumArray (1 to 11, 1)

    I'm not sure how I can get SumArray = Array1 + Array2

    Thanks in advance.

  • Is this what you mean?

    I'm posting this on a computer that doesn't have Excel so I haven't test this code yet.

  • Thanks for responding baddyswing. I did something very similar to your answer. Not quite as clean and smooth however.

    I ended up creating a 1 dimensional sub array for both Array1 and Array2 and then add that together. Not realizing that I could sum them together like you showed.

    I really appreciate your response.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!