Sub testCov()
Rng2 = Sheets("20 Asset Model").Range("b3:f48")
Dim covMatrix() As Variant
ReDim covMatrix(1 To Rng2.Columns.Count, 1 To Rng2.Columns.Count)
Call constructCovMatrix(Rng2, covMatrix)
MsgBox (covMatrix)
End Sub
Sub constructCovMatrix(rng, ByRef covMatrix)
'@rng The Range of the return series.
Dim i As Integer
Dim j As Integer
For i = 1 To rng.Columns.Count
For j = 1 To rng.Columns.Count
covMatrix(i, j) = Application.WorksheetFunction.Covar(rng.Columns(i), rng.Columns(j))
Next
Next
End Sub
代码停在 ReDim 行,说对象丢失。为什么是这样?谢谢