View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Using Macros to ask the user to enter a date

Thank you for the advice
--
Gary's Student
gsnu200705


"JE McGimpsey" wrote:

Note, though, that this throws a run-time error if the user cancels or
enters a non-date (including a blank). It's a little more user-friendly
to use something like:

Public Sub Demo()
Dim d As Date
Dim vAnswer As Variant
Do
vAnswer = Application.InputBox("Enter date", "Title")
If vAnswer = False Then Exit Sub 'user cancelled
Loop Until IsDate(vAnswer)
d = CDate(vAnswer)
MsgBox d
End Sub


In article ,
Gary''s Student wrote:

for flexibility on input formats:

Sub demo()
Dim d As Date
d = DateValue(Application.InputBox("Enter Date: ", 2))
MsgBox (d)
End Sub