?
Solved

VBA for Excel 2010

Posted on 2014-02-17
3
Medium Priority
?
558 Views
Last Modified: 2014-02-17
I have a VBA UserForm within Excel 2010 and on it is a Date text box.  I want the Text Box to perfill with Today's date when the UserForm is called.  What is the code to make this happen?   Is there another control I should be using.  The value prefilled or entered by my user in the TextBox will be placed into the Excel worksheet.
0
Comment
Question by:cowboywm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39865346
TextBox1.Text = Format(Now(), "short date")
0
 
LVL 31

Accepted Solution

by:
gowflow earned 1500 total points
ID: 39865426
for the first part MartinLiss gave you the solution

and for
 The value prefilled or entered by my user in the TextBox will be placed into the Excel worksheet.

then you put in ControlSource property of the textbox
TextBox1.ControlSource = "Sheet1!A1"
'Place the result of the textbox into sheet1 of cell A1

gowflow
0
 

Author Closing Comment

by:cowboywm
ID: 39866234
Thank you all for your input.  This is the final code.

Private Sub UserForm_Initialize()
    DateTextBox.Text = Format(Now(), "short date")
End Sub

I also have a macro that dumps the data to the correct spot on the spreadsheet once the command button is clicked.  Here is the portion dealing with the date data.

Private Sub StopCommandButton_Click()
    ActiveCell.Offset(0, -8).Range("A1").Activate   'Moves to Date Field(cell)
    MyAnswer = DateTextBox.Text
    ActiveCell.FormulaR1C1 = MyAnswer
End Sub
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question