Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Date Formatting

Is there a way to specify that a Date format can only be
in MM-DD-YY, not MM/DD/YY?

If Answer = "" Then Exit Sub
If Not IsDate(Answer) Then
MsgBox "Invalid Date!"
Exit Sub
End If

This will confirm that it is a date, but won't distinguish
between / and -.

Thanks

S.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Date Formatting

Maybe something like this?

Sub Test()

Dim Answer As String

Answer = Trim(InputBox("Enter date in DD-MM-YY format"))
If Answer = "" Then Exit Sub
If Not IsDate(Answer) Then
MsgBox "Invalid Date!"
Exit Sub
End If
If Mid(Answer, 3, 1) < "-" Or _
Mid(Answer, 6, 1) < "-" Or Len(Answer) < 8 Then
MsgBox "You must use 2 digits for day, month and year" _
& " and you must use hyphen (-) as the separator"
Exit Sub
End If

End Sub

--
HTH,
Dianne

In ,
S. S. typed:
Is there a way to specify that a Date format can only be
in MM-DD-YY, not MM/DD/YY?

If Answer = "" Then Exit Sub
If Not IsDate(Answer) Then
MsgBox "Invalid Date!"
Exit Sub
End If

This will confirm that it is a date, but won't distinguish
between / and -.

Thanks

S.



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
conditional formatting for cell date to equal today's date Sistereinstein Excel Worksheet Functions 2 September 10th 12 07:53 PM
Date Formatting (*) jbc Excel Discussion (Misc queries) 2 October 9th 06 06:09 PM
Formatting the date nick Excel Discussion (Misc queries) 1 May 10th 06 04:01 PM
XML Date formatting Richard Roche Excel Discussion (Misc queries) 0 April 11th 06 04:34 PM
date formatting BernieH Excel Discussion (Misc queries) 2 May 30th 05 03:33 PM


All times are GMT +1. The time now is 09:58 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"