Bonjour,
J'écris un code me permettant de calculer la volatilité
voici le code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Le problème c'est que ma fonction s'arrête à ce niveau
Code : Sélectionner tout - Visualiser dans une fenêtre à part
   If TableauPoids(i) = Empty Then
et ne me donne aucun résultat. Et quand je met cette partie du code en commentaire, elle s'arrête à ce niveau
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
TableauVariances(i) = TableauPoids(i) * TableauPoids(i) * TableauMatrice(i, i)
En fait quand je dis qu'elle s'arrête, ca ve dire qu'elle se comporte comme si j'avais mis Exit Function à ce niveau

Je ne sais pas pourquoi elle se comporte ainsi. Une idée?
Thank's