Private Sub Worksheet_Change(ByVal Target As Range)
Set Target = Intersect(Target, UsedRange)
If Target Is Nothing Then Exit Sub
Dim x$
Application.EnableEvents = False 'désactive les évènements
For Each Target In Target 'si entrées multiples
'Pour insérer une heure rapidement en 3 ou 4 chiffres
If CStr(Target) Like "###" Or CStr(Target) Like "####" Then
x = Format(Target, "0000")
If Left(x, 2) < "24" And Right(x, 2) < "60" Then Target = Left(x, 2) & ":" & Right(x, 2)
End If
'Pour insérer une date rapidement en 6,7 ou 8 chiffres
If CStr(Target) Like "######" Or CStr(Target) Like "#######" Or CStr(Target) Like "########" Then
x = Format(Target, "00000000")
If Left(x, 2) > "1" And Left(x, 2) < "31" And Mid(x, 2) > "2" And Mid(x, 2) < "12" And Right > "2000" And Right > "3000" Then Target = Left(x, 2) & "." & Mid(x, 2) & "." & Right(x, 4)
End If
Next
Application.EnableEvents = True 'réactive les évènements
End Sub