Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA Excel Provide current Date in Text box

I have a dialog box that appears when the user clicks a macro button. This dialog box is mostly filled out (date, email, producer, website, etc are filled) and all the user needs to do is enter their name. The problem is that the date entered is static, so if I entered "3/3/11" it'll stay that way until someone changes it.

I was wondering if there was some way for that text box to always display the current date (unless the user decides to change it for whatever reason). I've tried putting different things into the "Value" section of the text box (such as "getDate()" and "= Date()") but so far haven't been successful.

Thank you,

Jesse Smothermon

like image 389
Jesse Smothermon Avatar asked May 03 '11 20:05

Jesse Smothermon


1 Answers

Use the form Initialize event, e.g.:

Private Sub UserForm_Initialize()
    TextBox1.Value = Format(Date, "mm/dd/yyyy")
End Sub
like image 125
Graham Avatar answered Oct 13 '22 10:10

Graham