Excel IF function

February 22, 2011 at 17:42:51
Specs: Macintosh
Hi, i am trying to write a function for say cell E23 that if E24 has a date in it the E23 returns a 1, if E24 has any other value or blank then E23 returns a 2. Help...Thanks

See More: Excel IF function

Report •

February 22, 2011 at 20:03:08
There is no "ISDATE" function in Excel, but there is one in VBA which you can use to create a User Defined Function or UDF.

Press Alt-F11 to open the VBA editor.

Choose Insert...Module

Paste this code into the window that opens:

Function IsDate(cell) As Boolean
  IsDate = VBA.IsDate(cell)
End Function

Using =IsDate(A1) in a worksheet will return either TRUE or FALSE, therefore =IF(IsDate(A1),1,2) will return either 1 or 2.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

February 23, 2011 at 12:22:17
WOW thankyou & it works !!! You're awesome - I loveyou !!

Report •

February 23, 2011 at 17:33:51
As DerbyDad03 said, There is no "ISDATE" function in Excel,
but you can get something close without using a UDF,
it is not as elegant or simple as DerbyDad03s function, but it does work (almost always):


This will cover all of the "common" date formats,
it's not bullet proof, as there are several "date" formats that can fool it,
but should work for most dates.

But, it is really only just an interesting bit of coding.



Report •

Related Solutions

Ask Question