View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Stubborn Date Format

On Mon, 3 Apr 2006 22:53:57 -0400, "Tom Ogilvy" wrote:

masterworkbook.Sheets("shipper").Cells(7, 8).Value = cDate(strFormatDate)

should solve your problem.

"26/04/2006" can't be misinterpreted.

"03/04/2006" is ambiguous. It is a legitimate date either way.


It's interesting how VBA works with regard to the Regional Settings.

It seems that within VBA, it does interpret dates in accord with the Windows
Regional settings. (That's why CDate works properly).

However, if it writes a string formatted as a date to an Excel cell, that
string gets converted to a US-centric date.

If that string is first converted within VBA to a true date (i.e. with the
CDate function), then the result is a date interpreted in accord with the
Windows Regional settings.

Weird.

--ron