VBA DATE FORMAT : dd/mm/yyyy

whitewhisper

New Member
Joined
Jul 7, 2014
Messages
6
I have a userForm that asks the date of birth of a client.
The date has to be entered in the textBox only like this format: dd/mm/yyyy or else I don't want it to accepted (For example: this format should NOT work: mm/dd/yyyy )

I need help with the code... thanks!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
This will be problematic for ambiguous dates (Day is 12 or less).
Say If the user entered 7/11/2014

It would be impossible for VBA to know if the user's 'Intent' was for that to be November 7th, or July 11th.

You can dictate to VBA that it should treat it as November 11th.
But that does nothing to prevent the user from actually entering it that way believing it to be July 11th.

The best you could do is to put an instruction in the message box that it needs to be entered as dd/mm/yyyy

The only way I can think of that would be absolute.
Is to force the user to enter the month Name like Nov 7, 2014 or similar.
 
Upvote 0

Forum statistics

Threads
1,215,633
Messages
6,125,925
Members
449,274
Latest member
mrcsbenson

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