View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Differentiate between Number and Date?

That's because there is no date type in Excel, dates are just numbers since
1st Jan 1900. You need a UDF, something like

Function CellType(rng As Range)
If rng.Count = 1 Then
If IsDate(rng) Then
CellType = "D"
ElseIf IsArray(rng) Then
CellType = "A"
ElseIf IsNumeric(rng) Then
CellType = "N"
ElseIf IsError(rng) Then
CellType = "E"
Else
CellType = "T"
End If
End If
End Function


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Merle" <u17293@uwe wrote in message news:59df29d1dce57@uwe...
I'm trying to determine the type of information in each column. I was

using
the TYPE function but it doesn't differentiate between a Number and a

Date.
The dates in my cells are either:

3/21/1999
3/21/1999 20:31:56 PM

...both of which Excel reads as a Number (type=1)

I want, basically:

if(type(A1)=1,"N",if(type(A1)=2,"C"...etc., so that my result in the cell

is
either N, D, C, or L

Any ideas?

Merle