Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- Sub testCov()
- Dim Rng2 As Range '- Declare variable
- Set Rng2 = Sheets("20 Asset Model").Range("b3:f48") '-Set range
- Dim covMatrix() As Variant
- ReDim covMatrix(1 To Rng2.Columns.Count, 1 To Rng2.Columns.Count)
- Call constructCovMatrix(Rng2, covMatrix)
- MsgBox (covMatrix)
- Set Rng2 = Nothing '- Cleanup anytime 'Set' is used
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement