Bonsoir le forum,
Pouvez-vous svp m'aider svp pour une saisie rapide des dates,
En plus de intitulé, vous trouverez davantage d'explications dans le fichier ci-joint.
Merci d'avance aux pros de VBA,
Cordialement
Private Sub Worksheet_Change(ByVal Target As Range)
If Selection.Count > 2 Or Target.Style <> "MaDate" Then Exit Sub
Select Case Len(Target.Text)
Case 6: Target.Value = DateSerial(Mid(Target.Value, 5, 2), Mid(Target.Value, 3, 2), Mid(Target.Value, 1, 2))
Case 7: Target.Value = DateSerial(Mid(Target.Value, 4, 4), Mid(Target.Value, 2, 2), Mid(Target.Value, 1, 1))
Case 8: Target.Value = DateSerial(Mid(Target.Value, 5, 4), Mid(Target.Value, 3, 2), Mid(Target.Value, 1, 2))
End Select
End Sub
If Target Like "######" Then Target.Value = DateSerial(Mid(Target.Value, 5, 2), Mid(Target.Value, 3, 2), Mid(Target.Value, 1, 2))
Private Sub Worksheet_Change(ByVal Target As Range)
If Selection.Count > 2 Or Target.Style <> "MaDate" Then Exit Sub
If Target Like "######" Then Target.Value = DateSerial(Mid(Target.Value, 5, 2), Mid(Target.Value, 3, 2), Mid(Target.Value, 1, 2))
If Target Like "########" Then Target.Value = DateSerial(Mid(Target.Value, 5, 4), Mid(Target.Value, 3, 2), Mid(Target.Value, 1, 2))
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Selection.Count > 2 Or Target.Style <> "MaDate" Then Exit Sub
If Target Like "######" Then
Target.Value = DateSerial(Mid(Target.Value, 5, 2), Mid(Target.Value, 3, 2), Mid(Target.Value, 1, 2))
exit sub
end if
If Target Like "########" Then
Target.Value = DateSerial(Mid(Target.Value, 5, 4), Mid(Target.Value, 3, 2), Mid(Target.Value, 1, 2))
exit sub
end if
Msgbox "Format de date incorrect"
End Sub