Verify The accuracy of a date

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hello all,

I have a user form which the date is selected from 3 different dropdown boxes (month, day, year)... Those values are then entered into my sheet in C3:5.
My problem is that someone could in theory plan something for "June 31st" or February 30th" for example. Is there an effective way to validate that the date chosen does actually exist prior to moving forward with my userform?

Thanks,
Andrew
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
You can try and convert the date to a Date value using CDate. If an error occurs, it is not a valid date.
 
Upvote 0
Try testing the date string with IsDate(). Here's results from the Immediate Window.

Code:
? IsDate("02/29/2016")
True
? IsDate("02/29/2017")
False
? IsDate("6/30/2018")
True
? IsDate("6/31/2018")
False
 
Upvote 0
Now the values appear in separate cells though:

C3: May
C4: 1
C5: 2018

So I would have to combine into a date value first?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top