Click inside userform textbox to enter date

OfficeUser

Well-known Member
Joined
Feb 4, 2010
Messages
544
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Is it possible to click inside a userform textbox and populate using todays date? Thanks.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
How about
Code:
Private Sub [COLOR=#ff0000]WghtBx[/COLOR]_enter()
[COLOR=#ff0000]WghtBx [/COLOR]= Date
End Sub
Changing the bits in red to match the name of your textbox. This needs to go in the UserForm module
 
Last edited:
Upvote 0
You could try one of these two. With the TextBox1_Change, if you click in the box and hit any key the date will come up. The Double Click says it all...

Code:
Private Sub TextBox1_Change()
    Me.TextBox1.Value = Date
End Sub
or


Code:
Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Me.TextBox1.Value = Date
End Sub
 
Upvote 0
Thanks for the solutions, all of them worked.
 
Last edited:
Upvote 0
Great! Glad we could help. Thanks for the feedback!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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