ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Entering dates in vba inputbox as ddmmyy. Excel returns mmddyy (https://www.excelbanter.com/excel-programming/338593-entering-dates-vba-inputbox-ddmmyy-excel-returns-mmddyy.html)

pkeegs

Entering dates in vba inputbox as ddmmyy. Excel returns mmddyy
 
I am using an inputbox in VBA to return a date into an excel cell. When I
enter the date as dd mm yy, excel returns it as mm dd yy, irrespective of how
I have formatted the receiving cell. It only applies to the lower numbers
such as 06/07/05. If I were to enter 25/07/05, it would return correctly.

Bob Phillips[_6_]

Entering dates in vba inputbox as ddmmyy. Excel returns mmddyy
 
You must be in the UK or Europe.

In VBA, all dates are treated as US style dates. Obviously, 25/07/2005 is
unambiguous, but 06/07/2005 isn't, so VBA treats it as US style.

You can force it rather than use the VBA default date casting, using CDate,
example

activecell.Value = cdate(inputbox("Input date"))


--

HTH

RP
(remove nothere from the email address if mailing direct)


"pkeegs" wrote in message
...
I am using an inputbox in VBA to return a date into an excel cell. When I
enter the date as dd mm yy, excel returns it as mm dd yy, irrespective of

how
I have formatted the receiving cell. It only applies to the lower numbers
such as 06/07/05. If I were to enter 25/07/05, it would return correctly.




pkeegs

Entering dates in vba inputbox as ddmmyy. Excel returns mmddyy
 
Thanks Bob, that was spot-on

"Bob Phillips" wrote:

You must be in the UK or Europe.

In VBA, all dates are treated as US style dates. Obviously, 25/07/2005 is
unambiguous, but 06/07/2005 isn't, so VBA treats it as US style.

You can force it rather than use the VBA default date casting, using CDate,
example

activecell.Value = cdate(inputbox("Input date"))


--

HTH

RP
(remove nothere from the email address if mailing direct)


"pkeegs" wrote in message
...
I am using an inputbox in VBA to return a date into an excel cell. When I
enter the date as dd mm yy, excel returns it as mm dd yy, irrespective of

how
I have formatted the receiving cell. It only applies to the lower numbers
such as 06/07/05. If I were to enter 25/07/05, it would return correctly.





Bob Phillips[_6_]

Entering dates in vba inputbox as ddmmyy. Excel returns mmddyy
 
I'm in the UK myself, so I suffer these problems :-)

Bob


"pkeegs" wrote in message
...
Thanks Bob, that was spot-on

"Bob Phillips" wrote:

You must be in the UK or Europe.

In VBA, all dates are treated as US style dates. Obviously, 25/07/2005

is
unambiguous, but 06/07/2005 isn't, so VBA treats it as US style.

You can force it rather than use the VBA default date casting, using

CDate,
example

activecell.Value = cdate(inputbox("Input date"))


--

HTH

RP
(remove nothere from the email address if mailing direct)


"pkeegs" wrote in message
...
I am using an inputbox in VBA to return a date into an excel cell.

When I
enter the date as dd mm yy, excel returns it as mm dd yy, irrespective

of
how
I have formatted the receiving cell. It only applies to the lower

numbers
such as 06/07/05. If I were to enter 25/07/05, it would return

correctly.







All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com