I want to check to make sure the contents of a cell is in the date format before I run a DateDiff so as to avoid possible errors, any idea how I could do that?
I want to check to make sure the contents of a cell is in the date format before I run a DateDiff so as to avoid possible errors, any idea how I could do that?
Use the IsDate function. It returns True if the reference is recognizable as a date and False if it's not. Example:
Sub dtechck()
If IsDate(Range("A1")) Then
Range("B1").Value = "a Date"
Else: Range("B1").Value = "no Date"
End If
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks