Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Checking for valid dates on entry

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,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Checking for valid dates on entry

1. trap the change with the change event
2. determine if it is a cell of concern
3. Use the IsDate() function to test for valid
--
Gary''s Student


"Ian" wrote:

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,

  #3   Report Post  
Posted to microsoft.public.excel.programming
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,



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
checking hyperlinks are valid Rafael Guerreiro Osorio Excel Discussion (Misc queries) 2 April 4th 23 12:57 PM
checking hyperlinks are valid Garbagh Excel Discussion (Misc queries) 2 September 21st 17 05:04 PM
checking hyperlinks are valid Garbagh Excel Discussion (Misc queries) 0 November 30th 06 02:16 PM
checking hyperlinks are valid Rafael Guerreiro Osorio Excel Discussion (Misc queries) 0 November 30th 06 01:34 PM
Checking If Hyperlink Is Valid Steve[_32_] Excel Programming 2 September 14th 03 03:05 AM


All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"