Is cell content a date?

  • Thread starter Thread starter papa jonah
  • Start date Start date
P

papa jonah

I am trying to use a series of If statements to determine how some rows
should be formatted.
It is all pretty easy based on dates in a certain column. However, the
user often substitutes dates with text.
How can I have the code evaluate the contents of a cell to determine if
it is a date or not?

TIA
 
I am trying to use a series of If statements to determine how some rows
should be formatted.
It is all pretty easy based on dates in a certain column. However, the
user often substitutes dates with text.
How can I have the code evaluate the contents of a cell to determine if
it is a date or not?

TIA

If you are talking about worksheet function code, there are a number of
approaches.

You could check to see if it is a number (ISNUMBER) within the possible date
range. Excel stores dates as serial numbers with 1 = 1/1/1900 (or 1/2/1904 if
using the 1904 date system).

If it is not a number, you could see if you get an error when executing the
DATEVALUE function (which could convert date entered as text into a date).
ISERROR(DATEVALUE(entry)). And so forth.

If you are talking about a VBA function, then you can use the ISDATE function.


--ron
 
Back
Top