我看到很多例子显示RNG指定为静态输入(EX ... A1:A3)
我希望传递任何范围,而不必在内部进行子指定,即动态
Function sMad(rng As Range)
Dim count As Double
Dim rCell As Range
Dim medianMatrix() As Double
'bad estimator for count, only measures 1 column
'count = rng.count
...
For i = 0 To count
...
Next i
sMad = count
End Function
更新
我之前未能包含我的代码的正确截断视图(根据任何atm计算isn&t;但它应该基于rng.count)但是,我确实弄清楚如何循环访问但是,我最终试图在每个位置读取每个单元格的值。
Function sMad(rng As Range)
Rem sMad = LoopRangeApplication.WorksheetFunction.Sum(rng)
Dim count As Double
For Each cell In rng
count = count + 1
Next cell
sMad = count
End Function