Public Sub convertit()
Dim DateString As String
Dim DateD As Date
Dim FilterDate As String
DateString = InputBox(prompt:="Enter date dd.mm.yyyy", Title:="Enter Date")
If DateString = "" Then
MsgBox "User cancelled."
ElseIf Not DateString Like "[0-9][0-9].[0-1][0-9].20[0-3][0-9]" And _
Not DateString Like "[0-9][0-9].[0-1][0-9].19[0-9][0-9]" _
Then
MsgBox DateString & " is not a valid date in the form dd.mm.yyyy"
Else
On Error GoTo BadDate
DateD = DateValue(Left(DateString, 2) & "/" & Mid(DateString, 4, 2) & "/" & Right(DateString, 4))
On Error GoTo 0
FilterDate = Format(DateD, "m/d/yyyy")
MsgBox "Use " & FilterDate & " to build AutoFilter"
End If
Exit Sub
BadDate:
MsgBox DateString & " is in the correct format but is not a valid date"
End Sub