Option
Explicit
Sub
Test()
ThisWorkbook.Sheets(
"Tabelle1"
).Range(
"g13"
).Value = _
TestIt(InputBox(
"Wann geprüft? Bitte Datum eingeben!"
, , Format(Now,
"DD.MM.YYYY"
)))
End
Sub
Function
TestIt(strInput
As
String
)
As
String
Const
strFail
As
String
=
"Bitte korrektes Datum eingeben"
Dim
dteDate
As
Date
On
Error
GoTo
Errorhandle
If
Len(strInput) = 10
Then
dteDate =
CDate
(strInput)
TestIt = Format(dteDate,
"DD.MM.YYYY"
)
Else
TestIt = strFail
End
If
Exit
Function
Errorhandle:
TestIt = strFail
End
Function