How do I include a date input box in a macro?
Taking Tim879's response a little further try this:
Dim usr_Date As Date
Dim tempResponse As Variant
ShowDateBox:
tempResponse = InputBox("Please enter date.", "Date Required",
Format(Now(), "dd-mmm-yyyy"))
If tempResponse = "" Then Exit Sub
If IsDate(tempResponse) = False Then GoTo ShowDateBox
usr_Date = tempResponse
usr_Date is a validated response that can be used elsewhere.
tempResponse is a variant to allow for any entry and holds the answer to the
input box, which is then tested for blank or valid date.
A 'Cancel', blank or Null entry stops execution.
If anything other than a date is entered the user is forced back to the
input box.
The above input box also has a default entry of today's date, if you don't
need that remove the 'format' bit to leave
'tempResponse = InputBox("Please enter date.", "Date Required")
HTH
Giz
"Tim879" wrote:
put a sample date in an unused cell of your spreadsheet. record your
macro....
after recording the macro, insert the following lines near the
beginning of your macro
dim usr_date as string 'you can call this whatever you want
usr_date = inputbox("Please enter a date: ")
find where you referenced the unused cell from above (for example
cell B1) and modify the code so that you now reference the usr_date
variable instead
On Jun 19, 9:08 am, Project Mgr <Project
wrote:
I want to record a macro which will show a input box into which I can enter
any date and then continue. I can't find the information in help how to do
this.
|