First enter the following UDF:
Function HotDate(r As Range) As Boolean
HotDate = False
v = r.Text
If Len(v) <> 10 Then Exit Function
If Not IsNumeric(Replace(v, "/", "")) Then Exit Function
If Not (Mid(v, 3, 1) = "/" And Mid(v, 6, 1) = "/") Then Exit Function
HotDate = True
End Function
this will return True if the argument has the desired form. So in B2 ( or
any other cell) enter:
=HotDate(A2)
So B2 will always reflect if the entry in A2 has the correct form.
Finally we can use Data Validation. Set the Data Validation on A2 to
FormulaIs:
=B2
Sorry about having to use an extra cell, but I have had little luck using
UDFs in Data Validation without a helper cell. (and besides, cells are cheap)
--
Gary''s Student - gsnu200771
"Andy" wrote:
> Will give it a go, thanks. Any thoughts on ensuring that a date has format
> dd/mm/yyyy?
>
> "Gary''s Student" wrote:
>
> > Data > Validation... > Custom > Formula Is >
> > =AND(A2=TRIM(A2),(LEN(A2)=8))
> > --
> > Gary''s Student - gsnu200771
|