Hey there,
I'm currently trying to do some error checking on a cell where the user has to enter the exact date format as "dd/mm/yyyy"
I have been using isDate to check if its a date and not text and then using the below function to check the exact format:
I've tried the above if statement but doesnt seem to be working for me. Does ayone have any idea's as to why it wont work as it has been driving me potty!Code:Function date_check() If Not (Range("C10").select = Format(CDate(Range("C10")), "DD/MM/YYYY")) Then MsgBox "The date was not entered correctly mate, please try again", vbInformation, "Add Non Conformity" date_check = 1 Exit Function Else date_check = 0 End If End Function
Cheers for any help,
Jag
Last edited by therealjag; 10-06-2009 at 08:04 AM.
Hi Jag
Let me ask why the date format matters - if the user enters a proper Excel date (which you can control eg with Data Validation) the format of the actual entered date shouldn't matter.
Richard
Richard Schollar
Microsoft MVP - Excel
Hey Richard,
Yeah perhaps I didnt explain fully but the reason I need it in the format dd/mm/yyyy is because I have to import the date into a different system and the import function only recognises dates in the format dd/mm/yyyy only unfortunately.
I've been tinkering around with the statement though and have managed to figure it out....the below statement now seems to do the job:
Code:Format(Range("C10").Value) <> Format(CDate(Range("C10").Value), "DD/MM/YYYY"
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks