ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   code pasting a date changes date format in current month only (https://www.excelbanter.com/excel-programming/297812-code-pasting-date-changes-date-format-current-month-only.html)

Edward[_5_]

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!


All times are GMT +1. The time now is 07:48 AM.

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