我有一个二维数组,我试图沿一维添加。二维数组是变体类型,可能有一些元素为空(“”)
这是到目前为止的代码
'newArray is 2D Array
Function SumColumn(newArray As Variant, index As Integer) As Double
Dim tempArray() As Double
ReDim tempArray(1 To UBound(newArray))
For i = 1 To (UBound(newArray))
tempArray(i) = CDbl(newArray(i, index))
Next
SumColumn = Application.WorksheetFunction.Sum(tempArray)
End Function
运行上述代码时出现类型不匹配错误。请帮我调试