Check if Cell a Date

  • Thread starter Thread starter Kim
  • Start date Start date
K

Kim

Is there a way to check if a cell contains a date. You can use ISTEXT for
text but there does not seem to be one for date. Any ideas?
 
Hi Kim

You can use a function in Excel to determine if a cell is numeric but I do
not think you can determine if the figure is a date. You could use a
function like the one below and then test whether a date exists in, say,
cell A3 by using the formula =querydate(A3)

Function QueryDate(c As Range)
QueryDate = IsDate(c)
End Function

Alternatively, you could use code such as...
Sub Is_It_a_Date()
If IsDate(Range("A1")) Then
MsgBox "Its a date"
Else
MsgBox "Its not a date"
End If
End Sub

--
XL2002
Regards

William

(e-mail address removed)

| Is there a way to check if a cell contains a date. You can use ISTEXT for
| text but there does not seem to be one for date. Any ideas?
|
|
 
Hi!

For Boolean TRUE and FALSE:

=ISLOGICAL(A1)

Or

=OR(--A1=1,--A1=0)

For dates:

Since true Excel dates are just serial numerics:

=ISNUMBER(A1)

If the date is actually a text string - 12/20/2004

=A1=TEXT(A1,"MM/DD/YYYY")

Biff
 
Back
Top