Skip to content

Instantly share code, notes, and snippets.

@magmel48
Last active May 12, 2017 18:50
Show Gist options
  • Save magmel48/5a32eb88934ccb3a651cdcc554ef8a89 to your computer and use it in GitHub Desktop.
Save magmel48/5a32eb88934ccb3a651cdcc554ef8a89 to your computer and use it in GitHub Desktop.
VBA
Dim text As String
Dim d As Date
Dim y As Integer
text = "28.02.1899"
If IsDate(text) Then
'Date is correct, let's check validity: date more than 1900 and less than 2010
d = CDate(text)
y = Year(d)
If Year > 1900 And Year < 2010 Then
'Date is valid, let's proceed with needed logic then
Else
'Year is invalid, let's show a message
'Use MsgBox here
End If
Else
'Date is invalid, let's show a message
'Use MsgBox here
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment