1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Function CalculVol(MatriceVarCov As Range, Poids As Range) As Double
Dim TableauMatrice(), TableauCovariance(), TableauVariances(), TableauPoids()
Dim i As Integer, j As Integer
Dim SoeVar, MaCov
TableauMatrice = MatriceVarCov.Value
TableauPoids=Poids.Value
If TableauPoids(i) = Empty Then
TableauPoids(i) = 0
End If
ReDim TableauVariances(1 To UBound(TableauMatrice, 1))
For i = 1 To UBound(TableauMatrice, 1)
TableauVariances(i) = TableauPoids(i) * TableauPoids(i) * TableauMatrice(i, i)
Next i
MaCov = 0: SoeVar = 0: i = 0
For i = 1 To UBound(TableauMatrice, 1)
SoeVar = SoeVar + TableauVariances(i)
For j = 1 To UBound(TableauMatrice, 1)
If j > UBound(TableauMatrice, 1) Then GoTo Suite
MaCov = MaCov + 2 * TableauMatrice(i, j) * TableauPoids(i) * TableauPoids(j)
Next j
Next i
Suite:
CalculVol = SoeVar + MaCov
End Function |
Partager