假设有两个1D阵列,每个阵列包含3个元素,如下所示
A 1
2 3
B C
如何将两个数组连接成一个带元素的单个数组
A1
23
BC
通过使用& amp;和表格操作很容易。或CONCATENATE函数,但如何在数组中执行此操作?
答案 0 :(得分:1)
遍历数组并将它们组合成第三个:
Sub foooooo()
Dim arr1() As Variant
Dim arr2() As Variant
Dim outArr() As Variant
arr1 = Array("A", "2", "B")
arr2 = Array("1", "3", "C")
ReDim outArr(UBound(arr1))
For i = LBound(arr1) To UBound(arr1)
outArr(i) = arr1(i) & arr2(i)
Next i
Debug.Print Join(outArr, ",")
End Sub