Another Date Format issue

W

Wayne Nelson

Hi,
I'm new to this forum and find it very useful. Thanks to all those wh
give advise and to all those who ask questions.
I have another date issue. The date is entered in an Input box. Th
variable is formated as "dd/mm/yy". The Excel spreadsheet and th
regional seetings are set to the same.
However if the first 2 numbers entered in the input box are less tha
13, VBA assumes its a month. The value becomes "mm/dd/yy"
ie Enter 12/10/03, output as 10/12/03
If the first 2 numbers are > 12, the correct date is entered in th
Excel spreadsheet.
ie Enter 21/10/03; output as 21/10/03.

Code as follows: ComD = InputBox("Please enter " & CtlNm & " Completio
Date.", "COMPLETION DATE:")

RepDa.Cells(Rw, 7).Value = Format(ComD, "dd/mm/yyyy"
 
N

Neil

Wayne,

Use cdate instead of format
RepDa.Cells(Rw, 7).Value = CDate(ComD)

Neil

Wayne Nelson said:
Hi,
I'm new to this forum and find it very useful. Thanks to all those who
give advise and to all those who ask questions.
I have another date issue. The date is entered in an Input box. The
variable is formated as "dd/mm/yy". The Excel spreadsheet and the
regional seetings are set to the same.
However if the first 2 numbers entered in the input box are less than
13, VBA assumes its a month. The value becomes "mm/dd/yy"
ie Enter 12/10/03, output as 10/12/03
If the first 2 numbers are > 12, the correct date is entered in the
Excel spreadsheet.
ie Enter 21/10/03; output as 21/10/03.

Code as follows: ComD = InputBox("Please enter " & CtlNm & " Completion
Date.", "COMPLETION DATE:")

RepDa.Cells(Rw, 7).Value = Format(ComD, "dd/mm/yyyy")


------------------------------------------------



~~Now Available: Financial Statements.xls, a step by step guide to
creating financial statements
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top