ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   input box for a date -- how to make an enter key the current date by default (https://www.excelbanter.com/excel-programming/431290-input-box-date-how-make-enter-key-current-date-default.html)

JasonK[_3_]

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

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



Jacob Skaria

input box for a date -- how to make an enter key the current date
 
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
---------------
Jacob Skaria


"JasonK" wrote:


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




JasonK[_3_]

input box for a date -- how to make an enter key the current date
 
Jacob,

that worked perfectly. thank you.

JasonK



On Sat, 18 Jul 2009 01:12:01 -0700, Jacob Skaria
wrote:

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
---------------
Jacob Skaria


"JasonK" wrote:


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






All times are GMT +1. The time now is 02:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com