View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Excel is changing date format incorrectly

Hi Garry,

Am Thu, 27 Nov 2014 10:26:20 -0500 schrieb GS:

Range("A1")="01/09/2014"

AFAIK, this is an OS setting! Up to XP Excel's default date format is
dd/mm/yyyy, but since Vista it's been mm/dd/yyyy. That concludes, then,
that this is a 'system' setting for how a date serial gets displayed.


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.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional