2017-02-18 73 views
0

我手動調換大型數組從記錄集(.transpose沒有工作),但第一列丟失。誰能告訴我哪裏出了錯VBA陣列轉置列丟失

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

一個下界下界'ArrRs1'零的?如果是這樣,你應該使用'0 To'而不是'1 To'(在聲明和循環中)。 – YowE3K

+0

@ YowE3K那麼看看,我不知道數組可以從0開始。謝謝! – Katie

+1

如果您不確定數組是基於0還是基於1的,請使用'LBound' –

回答

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 
+0

您是否檢查過第二維也不是基於零的? – YowE3K

+0

我做了,感謝您的檢查!另一個從1開始。 – Katie