View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim May Jim May is offline
external usenet poster
 
Posts: 430
Default Checking for valid dates on entry

Check out Data, Validation where you specify date range.

"Ian" wrote in message
...
I have a sheet where users enter dates. Other routines run and
highlight cells in different colours depending on the dates.

If a user enters a date with a leading space, it still appears in the
cell to be a date but VBA thinks it is not. It is acceptable to have
a blank cell.

I am trying to trap these errors with the change event, but cannot
get it to work.

Any ideas.



validdate = Now() + 730

If Len(Trim(cell.Value)) 0 And (cell.Value validdate) Then MsgBox
"invalid date"



Thanks,

Ian,