If its a date, then...

T

tony h

Unfortunately this is not straightforward.

isdate(range) will return a true or false depending on whether the cell
contents look like a date.

But remember a date in excel is only a format applied to a number. so
from the data it is not possible to distinguish between a date and a
number. There is a further confusion possible in that you can have text
that looks like a date but is not a number.

hope this helps
 
V

VBA Noob

This formula checks to see if cell fomatted as d-mmm-yy or dd-mmm-yy

See cell help for more examples.

it will still show "Y" if it looks like a date e.g '17/06/07 will still
return "Y"

=IF(CELL("format",A4)="D1","Y","")

VBA Noob
 
N

NickHK

As Tony explained, it depends on what you consider a date.
If you are happy to allow VBA to decide:
Public Function IsValueDate(argRange As Range) As Boolean
Dim tempDate As Date
On Error Resume Next
tempDate = argRange.Value
IsValueDate = (Err.Number = 0)
End Function

But you will see that this will produce some expected result.

NickHK
 
D

Dave Peterson

But there are other date formats.

maybe...

=IF(LEFT(CELL("format",A4),1)="D","Y","n")

And I think I'd check for a number, too. I can type text in a cell that's
formatted as a date.

=IF(AND(ISNUMBER(A4),LEFT(CELL("format",A4),1)="D"),"Y","n")

And to the OP, be aware that if you change the format of A4 (to General, say),
then the formula won't evaluate until the next recalculation.
 
D

Dave Peterson

Excel's help is not always bad <vbg>:

If the Microsoft Excel format is CELL returns
m/d/yy or m/d/yy h:mm or mm/dd/yy "D4"
d-mmm-yy or dd-mmm-yy "D1"
d-mmm or dd-mmm "D2"
mmm-yy "D3"
mm/dd "D5"
h:mm AM/PM "D7"
h:mm:ss AM/PM "D6"
h:mm "D9"
h:mm:ss "D8"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top