View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Edward[_5_] Edward[_5_] is offline
external usenet poster
 
Posts: 2
Default code pasting a date changes date format in current month only

I wrote some code to take a date from a cell on one sheet to a cell on
another, using a variable, which worked perfectly – until I noticed
that, if the date was in the current month, the days and months were
reversed when it pasted it in!! i.e. it changed to American date format.
Regional seetings are fine, the format for the cell is correct. Having
no idea how this could happen, I checked what happened if I pasted
manually – no problem. Then what would happen without using a variable:
the following snippet of code shows the problem:

ActiveCell.Offset(0, 14).Value = "29/04/04" - 29/04/04
ActiveCell.Offset(1, 14).Value = "30/04/04" - 30/04/04
ActiveCell.Offset(2, 14).Value = "01/05/04" - 05/01/04
ActiveCell.Offset(3, 14).Value = "02/05/04" - 05/02/04
ActiveCell.Offset(4, 14).Value = "03/05/04" - 05/03/04

It happens in both Excel 97 and also tried in 95. Can anyone shed light
on this and provide a solution? Many thanks in anticipation.

Edward


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!