对于用户定义的函数中的范围参数,只有将其作为变体类型处理时,才与极限速度兼容。例如,工作表上调用的函数 =MyFunc(A1:E4, 5, 4):
Function MyFunc (MyData As Variant, Rows As Long, Cols As Long) As Double
For I = 1 to Rows
For J = 1 to Cols
MsgBox MyData(I, J) 'or otherwise work with the cell range as an array
Next J
Next I
End Function