LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Input Box Asking for Date, and Validating Format

For the life of me, I cannot get this to work; either it keeps looping,
doesn't return the right message, or bombs out. All I'm trying to do is ask
the user to input a date in mm/dd/yy format.
1) If they hit cancel or don't enter anything, then they should get a
message saying they must enter a response.
2) If they enter something but it is not in the mm/dd/yy format, they should
get a message that it is not in the correct format.
3) If they enter it correctly, their response should be put into cell A1.

Can someone PLEASE help me? What I have is:
Sub GetDate()
Dim Response As String
Dim Msg As String
Msg = "Enter the contract start date, in mm/dd/yy format; then click on 'OK'."
Do
Response = InputBox(prompt:=Msg)
If Response = "" Then
MsgBox ("You must enter a response; please try again.")
End If
If Response < Format(CDate(Response), "mm/dd/yy") Then
MsgBox ("Enter a valid date in mm/dd/yy format; please try
again.")
End If
Loop
Range("A1").Value = Response
End Sub
 
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
Date input format Roy Gudgeon[_2_] Excel Discussion (Misc queries) 2 May 20th 10 02:05 PM
Validating Date Format exceed_novice Excel Worksheet Functions 5 February 7th 09 05:38 AM
validating input of textbox before publishing eyesonly1965 Excel Programming 4 May 7th 06 03:18 PM
validating input in textbox Jean-Pierre D via OfficeKB.com Excel Programming 1 August 15th 05 08:37 PM
Validating user input to a listbox Stuart[_5_] Excel Programming 3 September 6th 03 07:32 AM


All times are GMT +1. The time now is 12:28 AM.

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

About Us

"It's about Microsoft Excel"