Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$7" Then
If Target.Value <> "" Then
If Len(Target.Value) = 4 Then Target.Value = Mid(Target, 1, 2) & ":" & Mid(Target, 3, 2)
Else
MsgBox "Heure invalide"
Target.ClearContents
Cancel = True
Exit Sub
End If
'Valide que la valeur entrée est une heure valide
If Not IsDate(Format(Target, "hh:mm")) Then
MsgBox "Heure invalide"
Target.ClearContents
Cancel = True
End If
Else
Target.ClearContents
End If
End Sub