How to Display Today's Date Automatically in an Excel VBA UserForm TextBox
Question details
The user needs an Excel VBA UserForm TextBox to show the current system date automatically each time the form opens, using a consistent format such as 24 June 2020.

- Product
- Microsoft Excel VBA UserForm
- Device & OS
- not provided
- Scenario
- The user is designing a VBA UserForm and wants the date field to populate automatically with the current date instead of a fixed example date.
- Observed behavior
- The text box currently contains a fixed example date and does not update to the current date when the form opens.
Open the workbook that contains the UserForm and press Alt+F11 to enter the Visual Basic Editor. Note the exact Name property of the TextBox control that should receive the current date.
Set the TextBox Value in the UserForm_Initialize Event
Use this solution to populate the text box with the current system date each time the UserForm is initialized.
The UserForm_Initialize event runs automatically whenever the form is created, so it updates the date before the form appears.
The Format function converts the current date into a consistent text format such as 24 June 2020.
In Excel, press Alt+F11 to open the Visual Basic Editor. In the Project Explorer, double-click the UserForm that contains the TextBox control.
Right-click the UserForm and choose View Code to open its code window. If there is no existing UserForm_Initialize event, you can add one.
Enter the following code and replace TextBoxName with the actual control name: Private Sub UserForm_Initialize() TextBoxName.Text = Format(Date, "dd mmmm yyyy") End Sub
Press F5 or run the macro that opens the form, and confirm the text box shows the current date in dd mmmm yyyy format.

Automatically Display the Current Date in a WPS Spreadsheets VBA UserForm TextBox
Use the UserForm_Initialize event and the Format function in WPS Spreadsheets to set the current date in a text box, just as you would in Microsoft Excel.
- 1. Open the macro-enabled workbook in WPS Spreadsheets: Launch WPS Spreadsheets, open the .xlsm or .xls workbook containing the UserForm, and press Alt+F11 to open the VBA editor.
- 2. Locate the UserForm and target TextBox: In the Project Explorer, double-click the UserForm and note the exact Name property of the text box in the Properties window.
- 3. Add the UserForm_Initialize code: Right-click the UserForm, choose View Code, and enter Private Sub UserForm_Initialize() TextBoxName.Text = Format(Date, "dd mmmm yyyy") End Sub, replacing TextBoxName with the actual control name.
- 4. Run and verify the form: Press F5 or run the macro that opens the form, and confirm the text box displays the current date in dd mmmm yyyy format.

Frequently Asked Questions
Why does my UserForm TextBox still show the old fixed date after adding the code?
Make sure the code is inside the UserForm_Initialize event, not a button or worksheet event, and replace TextBoxName with the exact Name property of the text box. Then close and reopen the form or run it again.
How can I display the date as 24 June 2020?
Use Format(Date, "dd mmmm yyyy") in the UserForm_Initialize event. You can change dd, mmmm, or yyyy to other VBA date format codes if you need a different layout.
Will this VBA solution work in WPS Office Spreadsheets?
Yes. Open the macro-enabled workbook in WPS Spreadsheets, press Alt+F11 to open the VBA editor, and add the same UserForm_Initialize code to the UserForm.
What is the difference between Date and Now in VBA?
Date returns the current system date only, while Now returns the current date and time. Use Date for a date text box to avoid adding an unwanted time component.
Where can I find the exact TextBox name for the code?
In the VBA editor, select the text box on the UserForm and check the Name property in the Properties window. Press F4 if the Properties window is not visible.




