Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5195
  • Last Modified:

How do I add a date picker to a text box in a userform in Excel 2007

How do I add a date picker to a text box in a  userform in Excel 2007
0
bjfulkerson
Asked:
bjfulkerson
  • 5
  • 4
  • 2
1 Solution
 
Martin LissRetired ProgrammerCommented:
What do you mean when you say "add a date picker to a text box"? Do you mean that you want the result of the selection in a date picker to appear in a textbox?
0
 
bjfulkersonAuthor Commented:
I want to be able to pick a date from a calendar and populate a text box with that date.
0
 
EirmanCommented:
Here's a few links explaining how to place an ActiveX date picker control into an Excel 2007 worksheet ...

http://www.fontstuff.com/excel/exltut03.htm
http://www.rondebruin.nl/win/s8/win003.htm
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
bjfulkersonAuthor Commented:
Can this be done in a userForm
0
 
EirmanCommented:
Can this be done in a userForm
The second link above says ...
How to Create a userform with a calendar or Date Picker control on it
So it must be possible.

You could also try this free addon ...
http://www.excel-it.com/excel_datepickers.html
0
 
Martin LissRetired ProgrammerCommented:
You can achieve what you want by following these steps:

1.    Go to the Visual Basic IDE
2.    Select or add your userform
3.    If the Toolbox does not appear then click 'View' in the menu bar and select 'Toolbox'
4.    Right-click on the Toolbox and select 'Additional Controls...'
5.    If 'Selected Items Only' is checked, un-check it.
6.    Scroll down to 'Microsoft Date and Time Picker' control and select it.
7.    The control will now be in the toolbox and you can then select it and draw the control on your userform
8.    Finally, add this code

Private Sub DTPicker1_Change()
TextBox1.Text = DTPicker1.Value
End Sub

Open in new window

0
 
bjfulkersonAuthor Commented:
I am on Excel 2007, and I do not see that option.
0
 
Martin LissRetired ProgrammerCommented:
I'm not sure which "option" you mean, so please explain. But here is a demo workbook that shows the results of the above steps.
Q-28582649.xls
0
 
bjfulkersonAuthor Commented:
I got it to work.  

Private Sub Calendar1_Click()
TxtDate.Text = Calendar1.Value
End Sub
0
 
Martin LissRetired ProgrammerCommented:
I suggest you use the Change event instead.

Private Sub Calendar1_Change()
TxtDate.Text = Calendar1.Value
End Sub

Open in new window


But in any case I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0
 
bjfulkersonAuthor Commented:
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now