VBA阵列转置列缺失

时间:2017-02-18 03:58:49

标签: excel vba excel-vba

我手动转移记录集中的大型数组(.transpose不起作用),但缺少第一列。谁能告诉我哪里出错了

   Dim FinalArr As Variant

    ReDim FinalArr(1 To UBound(ArrRs1, 2), 1 To UBound(ArrRs1, 1))
    For i = 1 To UBound(ArrRs1, 2)
        For j = 1 To UBound(ArrRs1, 1)
            FinalArr(i, j) = ArrRs1(j, i)
        Next
    Next

1 个答案:

答案 0 :(得分:1)

数组的下界为0。

Dim PasteArray As Variant

ReDim PasteArray(1 To UBound(ArrRs1, 2), 0 To UBound(ArrRs1, 1))
For i = 1 To UBound(ArrRs1, 2)
    For j = 0 To UBound(ArrRs1, 1)
        PasteArray(i, j) = ArrRs1(j, i)
    Next
Next