Private Sub UserForm_Initialize()
Dim tablo() As String
Dim Temps As Long
TextBox5 = calcul("b", 1)
TextBox10 = calcul("e", 1)
TextBox9 = calcul("f", 1)
TextBox6 = Val(TextBox9) + Val(TextBox10)
TextBox7 = calcul("i", 2)
tablo = Split(TextBox7, ":")
If UBound(tablo) = 0 Then Exit Sub
Temps = (CLng(tablo(LBound(tablo))) * 60) + CLng((tablo(LBound(tablo) + 1))) 'temps en minutes
TextBox8 = CInt((CLng(TextBox5) / Temps) * 60)
End Sub
'code 1 valeur code 2 temps
Private Function calcul(col As String, code As Byte)
Dim Cellule As Range
Dim Heures As Long
Dim Minutes As Long
Dim Secondes As Long
Dim jours As Long
Dim nb1 As Long, nb2 As Long
With Sheets("Paramètre")
For Each Cellule In .Range(col & "3:" & col & .Range(col & .Rows.Count).End(xlUp).Row)
If code = 1 And IsNumeric(Cellule) Then calcul = calcul + Cellule
If code = 2 Then
If Cellule <> 0 Then
jours = Int(Cellule)
Heures = Heures + Hour(Cellule)
Minutes = Minutes + minute(Cellule)
Secondes = Secondes + Second(Cellule)
If Secondes > 59 Then
nb1 = Int(Secondes / 60)
Secondes = Secondes - nb1 * 60
Minutes = Minutes + nb1
End If
If Minutes > 59 Then
nb1 = Int(Minutes / 60)
Minutes = Minutes - nb1 * 60
Heures = Heures + nb1
End If
calcul = (Heures + jours * 24) & ":" & Minutes & ":" & Secondes
End If
End If
Next Cellule
End With
End Function