PDA

View Full Version : Sleeper: Validate a Date!??



Zuid-Holland
07-11-2005, 01:15 PM
Hey VBA-crackers,

I need some help!

I need to check if a certain cell (or range) has valid date value, how do i do it?
To elaborate further, i make my column, say column B, as format = date. The user is free to input anything in this column -- he may even copy some data from other column onto it, thus, erasing the date format. Now, i click validate button to check if this column B values are valid date values.

Tried with IsDate function, but wrong results.

Anyone please help me out with this .....

Thanks a ton!

Regards.

Bob Phillips
07-11-2005, 01:17 PM
Tried with IsDate function, but wrong results.

What wrong results do you mean?

Zack Barresse
07-11-2005, 04:16 PM
The IsDate function will return a boolean result, either True or False. When are you wanting to do this? At user input? You can protect a sheet so a user cannot change a value or formula. Dates are somewhat quirky in Excel though. This is because they are recognized as (serial) numbers. So it makes for somewhat of a challenge when differentiating between dates and a number.

If attempting this with standard worksheet functions, it's impossible. But if you want to use a UDF (User-Defined Function) this will work for you: http://www.vbaexpress.com/kb/getarticle.php?kb_id=323

johnske
07-11-2005, 04:29 PM
Hi Zuid-Holland,

How about using the inbuilt data validation tool? (Data -> Validation) If you select 'Date' you get many options and also a start and end date.

HTH,
John :)