input box for a date -- how to make an enter key the current date by default

J

JasonK

thanks for all your help --

i have a macro that has an input box that requires a date. is there a
way to make the current date the input if the user just hits ENTER
without typing a date?

Currently, if the user just hits enter, the macro crashes.

thanks again,

JasonK
 
J

Jacob Skaria

Jason, try the below

Sub Macro1()
Dim dtTemp As Date
varDate = InputBox("Enter Date", , Format(Date, "dd-mmm-yyyy"))
If IsDate(varDate) Then dtTemp = varDate Else dtTemp = Date
MsgBox dtTemp
End Sub

If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top