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
| Function calcul_TAT(f As Integer)
Dim r As Long, C As Long, J As Long
r = Cells(f, 3).Value
C = 0
J = 0
i = f
If Not IsEmpty(Cells(i - 1, 4)) Then
If IsNumeric((Cells(i - 1, 4))) Then
Do Until C + Cells(i, 4).Value >= r
C = C + Cells(i, 4): Cells(f, 14) = C
i = i - 1
J = J + 1
If Not IsNumeric(Cells(i, 4)) Then
Exit Do
End If
If IsEmpty(Cells(i, 4)) Then
Exit Do
End If
Loop
'Cells(f, 18) = J
X = f - J
'Cells(f, 19) = X
If Not IsEmpty(Cells(X, 4)) Then
If IsNumeric(Cells(X, 4)) Then
Cells(f, 15).Value = Cells(f, 14).Value + Cells(X, 4).Value
Else
MsgBox "Données historiques insuffisantes", vbExclamation, "Attention"
Cells(f, 15) = Cells(f, 14) * (J + 1) / J
Cells(f, 12).Interior.Color = RGB(255, 165, 0)
End If
Else
MsgBox "Données historiques insuffisantes", vbExclamation, "Attention"
Cells(f, 15) = Cells(f, 14) * (J + 1) / J
Cells(f, 12).Interior.Color = RGB(255, 165, 0)
End If
Cells(f, 14).EntireColumn.Hidden = True
Cells(f, 15).EntireColumn.Hidden = True
Cells(f, 16) = Cells(f, 3) / (Cells(f, 15) / (J + 1))
Cells(f, 16).EntireColumn.Hidden = True
Cells(f, 12) = Cells(f, 16)
Else
MsgBox "Données historiques insuffisantes", vbExclamation, "Attention"
Cells(f, 12).Interior.Color = RGB(255, 165, 0)
Cells(f, 12) = Cells(f, 3) / Cells(f, 4)
End If
Else
MsgBox "Données historiques insuffisantes", vbExclamation, "Attention"
Cells(f, 12).Interior.Color = RGB(255, 165, 0)
Cells(f, 12) = Cells(f, 3) / Cells(f, 4)
End If
calcul_TAT = Cells(f, 12)
End Function |
Partager