How do I Merge two Arrays in VBA?

Kevin Boyd picture Kevin Boyd · Oct 19, 2009 · Viewed 103.1k times · Source

Given

Dim arr1 As Variant
Dim arr2 As Variant
Dim arr3 As Variant

arr1 = Array("A", 1, "B", 2)
arr2 = Array("C", 3, "D", 4)

What kind of operations can I do on arr1 and arr2 and store result in arr3 such that:

arr3 = ("A", "C", 1, 3, "B", "D", 2, 4)

Answer

user3286479 picture user3286479 · Jan 9, 2017

Try this:

arr3 = Split(Join(arr1, ",") & "," & Join(arr2, ","), ",")