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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| Option Explicit
Public Function AvoirEpargne(Risk1 As String, Risk2 As String, Prime As Double, rend As Double, BirthDate As Date, gender As String, DateCalcul As Date, RiskAjout As String, _
AgeAjout As Double, RiskRetrait As String, ageRetrait As Double, AgeRetraitCap As Double) As Variant
Dim PrimeRisk1() As Double
Dim PrimeRisk2() As Double
Dim CumulAvoir As Double
Dim AvoirAnnee() As Double
Dim vecteur(4) As Variant
Dim CapitalAcquis As Double
Dim AvoirPrev As Double
Dim age As Double
Dim NmbMoisRetraite As Integer
Dim ArrayRisk1 As Range
Dim ArrayRisk2 As Range
Dim AgeRetraite As Integer
Dim j As Integer
Dim i As Integer
Dim colonne As Integer
'Paramètres frais
Dim FraisFixes As Double
Dim FraisPrimes As Double
Dim FraisAvoir As Double
Dim AugmPrimeAnnee As Double
FraisFixes = 100
FraisPrimes = 0.05
FraisAvoir = 0.004
AugmPrimeAnnee = 0.01 'Taux d'augmentation des primes par années
If gender = "F" Then colonne = 2 Else colonne = 3
'Calcul de l'âge exact
age = Year(DateCalcul) - Year(BirthDate) + Month(DateCalcul) / 12 - Month(BirthDate) / 12
'Age Retraite en fonction du genre
If gender = "F" Then AgeRetraite = 64 Else AgeRetraite = 65
'Calcul du nombre de mois avant retraite
NmbMoisRetraite = ((AgeRetraite - age) * 12)
ReDim PrimeRisk1(NmbMoisRetraite)
ReDim PrimeRisk2(NmbMoisRetraite)
'Definition des plages ou rechercher les primes de risque en fonction des offres chosie
Set ArrayRisk1 = ThisWorkbook.Sheets(Risk1).Range("A1:C100")
Set ArrayRisk2 = ThisWorkbook.Sheets(Risk2).Range("A1:C100")
' Création Array pour les primes de risk 1 & 2 et pour l'avoir de chaque année
For j = 1 To NmbMoisRetraite
PrimeRisk1(j) = Application.WorksheetFunction.VLookup(Int(age + i / 12), ArrayRisk1, colonne, False) * (1 + AugmPrimeAnnee) ^ (j - j + j / 12.1)
PrimeRisk2(k) = Application.WorksheetFunction.VLookup(Int(age + k / 12), ArrayRisk2, colonne, False) * (1 + AugmPrimeAnnee) ^ (j - j + j / 12.1)
Next j
' Calcul avoit total mensuel
For l = 1 To NmbMoisRetraite
AvoirAnnee(l) = Prime - PrimeRisk1(l) - PrimeRisk2(l) - FraisPrimes * (PrimeRisk1(l) + PrimeRisk2(l) ) - FraisFixes / 12
Next l
'Boucle Calcul de l'avoir à la retraite
CumulAvoir = 0
For i = 1 To NmbMoisRetraite
CumulAvoir = CumulAvoir * (1 + rend / 12) ^ (1 / 12) + AvoirAnnee(i) * (1 - FraisAvoir / 12)
Next i |
Partager