Hi. I want users to enter a date into a vba userform text box but with following conditions:
1. it must be entered as a 4 digit year
2. Prevent (trap) February 29th if "year" part of entry is not a leap year
I have searched without success for solutions. Obviously need to look at "year" to see if it meets usual leap year rules (divisible by 4 etc)
I cannot use "cdate" function because excel will not accept entry if not convertible to a valid date i.e. 29/02/2021 is not a valid date so cannot get past this point
Similarly cannot use "year" function on a non-valid date
I have found lots of suggestions for validating date input to ensure correct format (dd/mm/yyyy). also code to check for leap year, but nothing that combines the two - hope that is clear. Suggestions welcome
1. it must be entered as a 4 digit year
2. Prevent (trap) February 29th if "year" part of entry is not a leap year
I have searched without success for solutions. Obviously need to look at "year" to see if it meets usual leap year rules (divisible by 4 etc)
I cannot use "cdate" function because excel will not accept entry if not convertible to a valid date i.e. 29/02/2021 is not a valid date so cannot get past this point
Similarly cannot use "year" function on a non-valid date
I have found lots of suggestions for validating date input to ensure correct format (dd/mm/yyyy). also code to check for leap year, but nothing that combines the two - hope that is clear. Suggestions welcome