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 29 30 31 32
| Option Base 1
Sub prixspot()
Dim x() As Double, T() As Double, p() As Double, g() As Double
Dim i As Integer, j As Integer, x1() As Integer, x2() As Integer, v() As Integer
Dim somme() As Single
ReDim x(1000, 1), T(1000, 1), p(1000, 1), g(1000, 1), v(1000, 1), x1(1000, 1), x2(1000, 1), somme(1000, 1)
For i = 6 To Cells(Rows.Count, 1).End(xlUp).Row
somme(i) = 0
' NombreDeJour(i) = Cells(i, 12).Value - Cells(2, 1).Value 'definir le nombre de jours entre aujourd'hui et la date de fin
'NbreAnnées(i) = (Cells(i, 8).Value - Cells(2, 1).Value) / 360
x(i) = Cells(i, 15).Value / 30 'conversion du nombre de jours en mois a la ligne i
x1(i) = Int(x(i)) 'partie entiere de x(i)
x2(i) = x1(i) + 1
v(i) = Cells(i, 14).Value ' nombre d'année de la ligne i
g(i) = (x(i) - x1(i)) * 30
While v(i) > 0
For j = 1 To v(i)
p(j) = x(i) / 12 + (j - 1)
T(j) = (g(i) * Worksheets("Forwards").Cells(x2(i) + 11, 7).Value + 12 * (j - 1) + (30 - g(i)) * (Worksheets("Forwards").Cells(x1(i) + 11, 7).Value + 12 * (j - 1))) / 30
g(i) = (x(i) - x1(i)) * 30
somme(i) = Cells(i, 13).Value / (1 + T(j)) ^ p(j) + 100 / (1 + T(v(i)) ^ p(v(i)))
Next j
Wend
somme(i) = somme(i)
Cells(i, 11).FormulaR1C1 = "=somme(i)"
Next i
End Sub |
Partager