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

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 FunctionUsing =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.

WOW thankyou & it works !!! You're awesome - I loveyou !!

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):=IF(OR(CELL("format",A1)="D1",CELL("format",A1)="D2",CELL("format",A1)="D3",CELL("format",A1)="D4",CELL("format",A1)="D5"),1,2)

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 formostdates.But, it is really only just an interesting bit of coding.

MIKE

Ask Your Question

Weekly Poll