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