我有一个生成两个数组的函数(X
和Y
)。
我想通过将此数组传递给另一个函数BETA
来对此函数内的两个数组进行一些计算。这两个功能都可以完美地完成。我不知道如何正确地将数组传递给函数BETA
。这是内部函数的代码:
Function BETA(ByRef X As Range, ByRef Y As Range) As Variant
Dim i As Long
Dim B As Double
Dim X_SUM As Double, Y_SUM As Double
Dim X_MEAN As Double, Y_MEAN As Double
X_MEAN = Application.WorksheetFunction.Average(X)
Y_MEAN = Application.WorksheetFunction.Average(Y)
For i = 1 To UBound(X)
X(i) = X(i) - X_MEAN
Y(i) = Y(i) - Y_MEAN
Next i
X_SUM = WorksheetFunction.Sum(X)
Y_SUM = WorksheetFunction.Sum(Y)
B = (X_SUM * Y_SUM) / (X_SUM) ^ 2
BETA = B
End Function
答案 0 :(得分:0)
几个小问题:
BETA=B
作为回复?