1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Function timecalcul(cel, x)
Dim heure, mins
heure = Split(cel, ":")(0)
mins = Split(cel, ":")(1)
If Val(mins) = 0 Then mins = 30 Else heure = Val(heure) + 1: mins = 0
timecalcul = Format(heure, "00") & ":" & Format(mins, "00")
End Function
'
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 And Target.Count = 1 Then
Target.Offset(Target.Value, -1) = timecalcul(Target.Offset(0, -1).Text, Target.Value)
End If
End Sub
'
'juste pour tester
Sub test()
MsgBox timecalcul("07:00", 2)
MsgBox timecalcul("08:00", 2)
MsgBox timecalcul("08:30", 1)
End Sub |
Partager