0
如何正確轉置下列數組?我運行代碼時出現「超出範圍」錯誤。值應該從B2
開始填充。轉置陣列運行時錯誤'9'
Sub Checkb()
Dim acat As Variant
ReDim acat(0)
Dim contr As Control
For Each contr In UserForm2.Controls
If TypeName(contr) = "CheckBox" Then
If contr.Value = True Then
MsgBox (contr.Value)
acat(UBound(acat)) = contr.Name
ReDim Preserve acat(UBound(acat) + 1)
End If
End If
Next
ReDim Preserve acat(UBound(acat) - 1)
Sheets("TBL").Select
Range("B2").Resize(UBound(acat, 2), UBound(acat, 1)) = Application.Transpose(acat)
End Sub
'acat'是一維的。最後一行將其視爲二維。 – GSerg