hello.
I get this error when trying to calculate the matrix via VBA. Here's the code:
[CODE]
Function VarCovar(rng As Range) As Variant
Dim i As Integer
Dim j As Integer
Dim numCols As Integer
numCols = rng.Columns.Count
Dim matrix ( ) As Double
ReDim matrix (numCols - 1, numCols - 1)
For i = 1 To numCols
For j = 1 To numCols
matrix(i - 1, j - 1) = Application.WorksheetFunction.Covar(rng.Columns(i), rng.Columns(j))
Next j
Next i
VarCovar
End Function
[CODE]
Here are my returns:
22.90% 3.60% 4.10% 9.50%
37.40% 18.20% 8.60% 19.20%
1.20% 2.70% 0.10% 1.70%
0.50% 34.50% 65.40% 2.30%
Here is my error:
#VALUE! #VALUE! #VALUE! #VALUE!
#VALUE! #VALUE! #VALUE! #VALUE!
#VALUE! #VALUE! #VALUE! #VALUE!
#VALUE! #VALUE! #VALUE! #VALUE!
I've poured through code and formula [=varcovar(c3:f6) and I've done the ctrl+shift+enter. I really need help on this basic program.
Thanks.
Bookmarks