Hi Garry,
Am Thu, 27 Nov 2014 10:26:20 -0500 schrieb GS:
if he writes a DateSerial or a DateValue into the sheet the date will
be displayed with system settings.
But in this case the OP tries to write a string into the cell. That
string is in format (VBA speaks american English) mm/dd/yyyy. So d is
09 and m is 01. In his system he has the format dd/mm/yyyy so month
and day change places.
The only way to avoid this behaviour is to write
DateValue("01/09/2012"). That will be recognized as a date and will
be displayed correctly in his settings
Regards
Claus B.
Here's what I thought the OP was after...
[a2]=datevalue("27/11/2014")
...in the Immediate Window returns 11/27/2014 on both XP?/Win7. My read
of this post was that I thought the OP wanted to retain the fromat 'as
entered'. Since "01/09/2014 and "09/01/2014" can be interpreted either
way given the numeric values for d/m are valid for both d/m or m/d,
Excel interpret it 'as entered' to be a date.
If either numeric contains a value greater than 12 then Excel treats
the greater s dd. So this...
[a1]="11/27/2014" (dd/mm/yyyy)
gets treated as a valid date, but this...
[a2]="27/11/2014" (mm/dd/yyyy)
...gets treated as text.
--
Garry
Free usenet access at
http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion