我正在尝试将数组卸载到工作表中。此代码没有错误,但它创建了三行和多列(正如我所期望的那样):
Dim ToKeepArray() As Variant
ReDim ToKeepArray(1 To 3, 1 To LastRow) As Variant
'Populate the Array (this part works fine)
Dim TargetRange As Range
Set TargetRange = Sheets("TO_KEEP").Range(Cells(1, 1), Cells(1, 1))
TargetRange.Resize(UBound(ToKeepArray, 1), UBound(ToKeepArray, 2)).Value = ToKeepArray
但是,如果我试图通过使用:
转置整个事物TargetRange.Resize(UBound(ToKeepArray, 2), UBound(ToKeepArray, 1)).Value = Application.Transpose(ToKeepArray)
我收到Type Mismatch
错误;同样如果我放弃.value
。
我知道如何遍历数组(所以我可以找到我正在尝试做的解决方法)但是我错过了什么,为什么我会收到该错误?什么是不匹配的??