Bonjour,

J'ai un problème, je voudrai utiliser la fonction period_since_valo dans une autre fonction mais j'ai le code d'erreur incompatibilité de type.

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Function Period_since_valo(Frequence As Double, _
Date_valo As Double, _
Date_emmision As Double, _
NbColonne As Long) As Double()

Dim I As Integer

Dim Tab_period() As Double

ReDim Tab_period(NbColonne)

For I = LBound(Tab_period) To NbColonne

Tab_period(I) = 1 / Frequence * (I + 1) - ((Date_valo - Date_emmision) / 360)

Next I

Period_since_valo = Tab_period

Function Pricing_flow_bond(Coupon As Double, _
Principal As Double, _
Taux As Double, _
NbColonne As Long, Period_since_valo() As Double) As Double()

Dim I As Integer

Dim Flow_bond() As Double

ReDim Flow_bond(NbColonne)

For I = LBound(Flow_bond) To NbColonne

Flow_bond(I) = Coupon * Principal * Exp(-Taux * Period_since_valo)

Next I

Pricing_flow_bond = Flow_bond

End Function

Sub InsertionFlowB()

Dim Tbl3() As Double
Dim I As Long

Tbl3 = Pricing_flow_bond(Cells(7, 2).Value, Cells(6, 2).Value, Cells(8, 2).Value, Cells(4, 2).Value * Cells(5, 2).Value, Period_since_valo(Cells(4, 2).Value, Cells(3, 2).Value, Cells(2, 2).Value, Cells(4, 2).Value * Cells(5, 2).Value))
Si vous avez une piste ce serait top