Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default LEAP YEAR Validation

How do you validate a cell so it will only accept february 29th,yyyy if the year behind has a leap year in it?

For example:I do not want C2 to accept the date february 29,2003 but it can accept Febraury 29, 2004.

A B C D

1

2


Thank you
CTInt04










  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default LEAP YEAR Validation

Hi
just enter the date value in a date format and Excel should do the rest

--
Regards
Frank Kabel
Frankfurt, Germany


CTInt04 wrote:
How do you validate a cell so it will only accept february 29th,yyyy
if the year behind has a leap year in it?

For example:I do not want C2 to accept the date february 29,2003 but
it can accept Febraury 29, 2004.

A B C D

1

2


Thank you
CTInt04


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default LEAP YEAR Validation

Hi
disregard my previous post,, use William's suggestion

--
Regards
Frank Kabel
Frankfurt, Germany


Frank Kabel wrote:
Hi
just enter the date value in a date format and Excel should do the
rest


CTInt04 wrote:
How do you validate a cell so it will only accept february 29th,yyyy
if the year behind has a leap year in it?

For example:I do not want C2 to accept the date february 29,2003 but
it can accept Febraury 29, 2004.

A B C D

1

2


Thank you
CTInt04


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default LEAP YEAR Validation

You're right it works
Thanks

"Frank Kabel" wrote:

Hi
just enter the date value in a date format and Excel should do the rest

--
Regards
Frank Kabel
Frankfurt, Germany


CTInt04 wrote:
How do you validate a cell so it will only accept february 29th,yyyy
if the year behind has a leap year in it?

For example:I do not want C2 to accept the date february 29,2003 but
it can accept Febraury 29, 2004.

A B C D

1

2


Thank you
CTInt04



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default LEAP YEAR Validation


Hi CTInt04

Say you have:-
29-02-2004 in cell A1
29-02-2003 in cell A2

then the formula
=ISNUMBER(A1) in cell B1 will return TRUE
=ISNUMBER(A2) in cell B2 will return FALSE

So that is one way to check for the existence of a valid date. Note that
cells A1 and A2 should be formatted as dates.

--
XL2002
Regards

William



"CTInt04" wrote in message
...
| How do you validate a cell so it will only accept february 29th,yyyy if
the year behind has a leap year in it?
|
| For example:I do not want C2 to accept the date february 29,2003 but it
can accept Febraury 29, 2004.
|
| A B C D
|
| 1
|
| 2
|
|
| Thank you
| CTInt04
|
|
|
|
|
|
|
|
|
|




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default LEAP YEAR Validation

Hi CTInt04

Say you have:-
29-02-2004 in cell A1
29-02-2003 in cell A2

then the formula
=ISNUMBER(A1) in cell B1 will return TRUE
=ISNUMBER(A2) in cell B2 will return FALSE

So that is one way to check for the existence of a valid date. Note that
cells A1 and A2 should be formatted as dates.


--
XL2002
Regards

William



"CTInt04" wrote in message
...
| How do you validate a cell so it will only accept february 29th,yyyy if
the year behind has a leap year in it?
|
| For example:I do not want C2 to accept the date february 29,2003 but it
can accept Febraury 29, 2004.
|
| A B C D
|
| 1
|
| 2
|
|
| Thank you
| CTInt04
|
|
|
|
|
|
|
|
|
|


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default LEAP YEAR Validation

Thanks

"William" wrote:

Hi CTInt04

Say you have:-
29-02-2004 in cell A1
29-02-2003 in cell A2

then the formula
=ISNUMBER(A1) in cell B1 will return TRUE
=ISNUMBER(A2) in cell B2 will return FALSE

So that is one way to check for the existence of a valid date. Note that
cells A1 and A2 should be formatted as dates.


--
XL2002
Regards

William



"CTInt04" wrote in message
...
| How do you validate a cell so it will only accept february 29th,yyyy if
the year behind has a leap year in it?
|
| For example:I do not want C2 to accept the date february 29,2003 but it
can accept Febraury 29, 2004.
|
| A B C D
|
| 1
|
| 2
|
|
| Thank you
| CTInt04
|
|
|
|
|
|
|
|
|
|



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default LEAP YEAR Validation

How do you validate a cell so it will only accept february 29th,yyyy if
the year behind has a leap year in it?

For example:I do not want C2 to accept the date february 29,2003 but it

can accept Febraury 29, 2004.

Put the following in the worksheet's code module.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$C$2" Then Exit Sub
If IsDate(Target.Value) = False Then GoTo Skip
If Month(Target.Value) < 2 Then GoTo Skip
If Day(Target.Value) < 29 Then GoTo Skip
If Month(Target.Value + 1) < 3 Then GoTo Skip
Exit Sub

Skip:
Target.Value = ""
End Sub

HTH,
Merjet


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default LEAP YEAR Validation

Thanks

"merjet" wrote:

How do you validate a cell so it will only accept february 29th,yyyy if

the year behind has a leap year in it?

For example:I do not want C2 to accept the date february 29,2003 but it

can accept Febraury 29, 2004.

Put the following in the worksheet's code module.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$C$2" Then Exit Sub
If IsDate(Target.Value) = False Then GoTo Skip
If Month(Target.Value) < 2 Then GoTo Skip
If Day(Target.Value) < 29 Then GoTo Skip
If Month(Target.Value + 1) < 3 Then GoTo Skip
Exit Sub

Skip:
Target.Value = ""
End Sub

HTH,
Merjet



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
Leap Year BadBoy Excel Worksheet Functions 7 April 29th 09 11:49 PM
Leap Year Jet Excel Discussion (Misc queries) 3 March 20th 08 04:17 PM
Leap Year Ralph Page Charts and Charting in Excel 3 November 5th 07 01:57 AM
How to determine if year is a leap year Wanda Excel Worksheet Functions 7 September 17th 07 07:48 AM
Leap Year scrabtree23[_2_] Excel Programming 3 December 8th 03 03:36 PM


All times are GMT +1. The time now is 07:53 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"