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