Labels

Biography      Videos>     Cricket
Google
Showing posts with label VBA. Show all posts
Showing posts with label VBA. Show all posts

Wednesday, November 4, 2009

Problem in IsDate Function

There is a problem while using the IsDate Function. When we give invalid date like
"197703/02", Instead of returning false, the IsDate function returns true and consider it as a valid date. The work around for the problem is given below, A Custom IsDate function that validates the date and returns whether it is a valid or invalid.

Function MyIsDate(MyText)
If IsDate(MyText) Then
If 1 > Left(MyText, 2) > 12 Or Len(MyText) <> 8 Then
MyIsDate = False
Else
MyIsDate = True
End If
Else
MyIsDate = False
End If
End Function

VBA

1. VBA Error in IsDate Function