Date Format in a Text Box - UserForm

Eurekaonide

Active Member
Joined
Feb 1, 2010
Messages
433
Hi All

I am creating a UserForm in VBE (MS 2002)
I have a Text box which a date gets entered into by the user and the contents then gets populated into a set cell in the worksheet.

This all works fine, however I wondered if there was a way in pre-setting the date format in which to be entered? Thus not to confuse the US and UK formatting etc?

Many Thanks as always for your assistance.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I would suggest to offer three text boxes as inputs. One each for Month, Day, Year. Then the code would Concatenate them into a date.

Or offer three combo-box drop down lists.

Or offer a pop-up calendar style date picker when the user selects the date textbox.

With one of those methods, you'll avoid a lot of the date format input issues.
 
Upvote 0
This describes how to make a pop-up calendar userform.
A Pop-up Calendar for Excel

If your pop-up Calendar1 is on its own userform called CalendarForm and your date input textboox is TextBox1 on UserForm1, here's example code you could use to make it work...

UserForm1 module:
Code:
Private Sub TextBox1_Enter()
    CalendarForm.Show
End Sub

CalendarForm module:
Code:
Private Sub Calendar1_Click()
    UserForm1.TextBox1.Value = Calendar1.Value
    CalendarForm.Hide
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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