Excel - Code to determine if date in a cell is a real date
Good morning!
Here's my latest predicament. On rare occasions I've found non-existant dates (ie., 31-Feb-12) entered into the date column ("O") of one of our spreadsheets. That data feeds other formulas, macros, etc. and is easily overlooked during manual review as it's one of nearly 200 dates.
I'd like to add a few lines of code that would check the dates as entered to see if they are "real" dates, and if not then set the fill color to red, text to white, and add 1 to an error counter which eventually feeds a msg box that tells the user that x amount of errors were found.
Any help would be greatly appreciated.
Thanks,
Frank.M
Re: Excel - Code to determine if date in a cell is a real date
You might be able to use the Day() worksheet function. It returns #Value! for an invalid date.
Re: Excel - Code to determine if date in a cell is a real date
even the date posted above would to vba be a real date, by implicit conversion
Quote:
?day("31-Feb-12")
12