Skullmonkey
Computer
- Dec 10, 2001
- 12
I'm receiving a date in three parts (month,day,year) from a userform. Is there a prescripted VBA function that can check to see if this is a valid date? I have been using
to make this decision, but
will accept negative numbers, zeros, and numbers outside of my range (i.e. "70" as
is not a problem). Also, I'd like to make sure that the year is entered as a four-digit number.
Can I avoid hard-coding this? Or does Excel offer any tools for this sort of thing?
Any input would be appreciated.
SM
Code:
dtDate = CDate(DateSerial(iYear,iDay,iMonth))
bValidDate = IsDate(dtDate)
to make this decision, but
Code:
DateSerial
Code:
iDay
Can I avoid hard-coding this? Or does Excel offer any tools for this sort of thing?
Any input would be appreciated.
SM