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 81 82 83
| Sub Ecrire(Total1 As Double, Count As Integer, Colonne As Integer, Actualisation As Double)
Application.Volatile
Worksheets("XXX").Cells(Count, Colonne) = Total1 * Actualisation
End Sub
Function Calcul_Reconst (Phase As String, Objet1 As Double, Objet2 As Double, Annee As Double, DureeP1 As Double, DureeP2 As Double, DureeP3 As Double, Duree_totale As Double, _
Taux_Act As Double) As Double
Application.Volatile
Dim Total1 As Double
Dim Total As Double
Dim Actualisation As Double
Dim i As Integer
Dim Count As Integer
Dim Colonne As Integer
Dim k As Object
If Phase = "Phase 1" Or Phase = "MGlobale" Then
Count = 3
If Phase = "Phase 1" Then
Colonne = 2
ElseIf Phase = "MGlobale" Then
Colonne = 9
End If
ElseIf Phase = "Phase 2" Then
Count = DureeP1 + 4
Colonne = 2
ElseIf Phase = "Phase 3" Then
Count = DureeP2 + DureeP1 + 4
Colonne = 2
End If
Total1 = (Objet1 +Objet2) / Annee
Actualisation = 1
Total = Total1
MsgBox " Count = " & Count
MsgBox " Colonne = " & Colonne
MsgBox " Total1 = " & Total1
k = Application.Run("Ecrire", Total1, Count, Colonne, Actualisation)
MsgBox " Total1 = " & Total1
Actualisation = 1 + Taux_Act
Dim Annee2 As Integer
Annee2 = CInt(Annee)
For i = (1 + Count) To (Annee2 - 1 + Count)
Total = Total + Total1 * Actualisation
k = Application.Run("Ecrire", Total1, i, Colonne, Actualisation)
MsgBox " Total = " & Total
Actualisation = Actualisation * (1 + Taux_Act)
Next i
Calcul_Reconst = Total
End Function |
Partager