Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, December 20, 2010 11:29 AM
Hi
I have a VB Macro in Excel and I want the user to enter a date in an Input Box in the format dd/mm/yy. The entry needs to be validated to ensure it is valid and if possible in dd/mm/yy format which if not would request another date is entered.
Could anybody assist with an example ?
Thanks
All replies (2)
Monday, December 20, 2010 11:57 AM âś…Answered | 2 votes
Here you have sample method how to format date and how to check is date is corect
Public Sub UserDate()
Dim strDate As String
strDate = InputBox("Insert date in format dd/mm/yy", "User date", Format(Now(), "dd/mm/yy"))
If IsDate(strDate) Then
strDate = Format(CDate(strDate), "dd/mm/yy")
MsgBox strDate
Else
MsgBox "Wrong date format"
End If
End Sub
Monday, December 20, 2010 12:25 PM
If this is a VBA question it is in the wrong Forum.
Click the following and then follow one of the links for VBA
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/717e3fc3-8840-446d-8b7a-55a4052f48d6