Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make the current date appear when i click 'enter' in a cell Matt_07 Excel Worksheet Functions 1 January 30th 07 09:32 AM
Make date change in excel to current date when opening daily? jamie Excel Discussion (Misc queries) 3 March 1st 06 03:37 PM
How do I enter a date range ie -7 from current date in MS QUERY notsmartenough Excel Discussion (Misc queries) 1 November 11th 05 10:17 PM
Can I automatically enter the current date or current time into a Ben New Users to Excel 7 October 19th 05 03:38 PM
enter a current date in a cell? Tpeyton77 Excel Discussion (Misc queries) 2 June 8th 05 02:30 AM


All times are GMT +1. The time now is 09:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"