The problem is that the underlying data for a date is a number. Whether you 'see' a date or not is just a case of formatting.
Todays date is seen by excel as 36978 days after 1 jan 1900. I don't know what the upper limit is, but any number you enter will be considered as a date by excel.
Can you explain what you are comparing, and I'm sure a solution can be made in another way.
You could check using a string and IsDate function:
Code:
Sub Check()
Dim sValue As String
sValue = Range("A1").Text
If IsDate(sValue) = True Then
MsgBox "It's a Date!"
Else
MsgBox "It's NOT a Date!"
End If
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.