![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi I have a form ready for use that I made on VBA. One of the fields is a date field, and all I want is for it to show as default today's date always What is the code for this? |
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
|
=TODAY()
|
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
Just use
=Date Wrap a format around it to display how you want it to appear eg =Format(Date, "mmmm dd yyyy") |
|
|
|
|
|
#4 |
|
Guest
Posts: n/a
|
This is sort of what I want, it's just that it is a text box and is empty at the moment by default. I want it so tat every time the form loads up, today's date is there as default, showing in the box
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
If it's named TextBox1, just use
TextBox1.Text = Date TextBox1.Locked = True ' So it can't be changed, also can do this via the textbox properties window in the form's UserForm_Initialize event (double-click on the form in the VBA editor, ignore the click event sub that comes up and choose the Initialize event from the right-hand drop-down). |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|