Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Dates Format changing when copying data between workbooks

Hi I am copying data from one sheet and pasting it into another
workbook.

Range("A1").Select
Selection.CurrentRegion.Select
Selection.Delete
Rows("1:1000").Select
Selection.Delete
Workbooks.Open Filename:="p:\pro65\csr01.xls"
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Copy
ActiveWindow.Close
Range("A1").Select

An example of the dates Before and After follows:
Note I require DD/MM/YYYY format
Note some cells have " - -"
BEFORE
- -
- -
1/11/2004
18/10/2004
10/08/2004
15/12/2004
10/12/2004
13/12/2004
12/11/2004

AFTER
- -
- -
11/01/2004
18/10/2004 PROBLEM
8/10/2004 PROBLEM
15/12/2004
12/10/2004 PROBLEM
13/12/2004
11/12/2004 PROBLEM

The problem:
If DD < 12 the the format changes from DD/MM/YYYY to MM/DD/YYYY

PS if I copy and paste the data manually I don't get the problem.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Dates Format changing when copying data between workbooks

Before you do the copying, format the cells in "csr01.xls" to
"dd/mmm/yyyy" -once the cells have been copied reformat them in the
destination workbook.to dd/mm/yyyy

Untested, but your code could be tightened up to something like..

Sub test()
Dim ws As Worksheet
Set ws = ActiveSheet
ws.Range("A1").CurrentRegion.Delete
ws.Rows("1:1000").Delete
Workbooks.Open Filename:="p:\pro65\csr01.xls"
With Workbooks("csr01.xls").Sheets("Whatever")
..Range("A1").CurrentRegion.NumberFormat = "dd/mmm/yyyy"
..Range("A1").CurrentRegion.Copy ws.Range("A1")
End With
Workbooks("csr01.xls").Close savechanges:=False
ws.Range("A1").CurrentRegion.NumberFormat = "dd/mm/yyyy"
ws.Range("A1").Select
End Sub


--


XL2003
Regards

William



wrote in message
oups.com...
Hi I am copying data from one sheet and pasting it into another
workbook.

Range("A1").Select
Selection.CurrentRegion.Select
Selection.Delete
Rows("1:1000").Select
Selection.Delete
Workbooks.Open Filename:="p:\pro65\csr01.xls"
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Copy
ActiveWindow.Close
Range("A1").Select

An example of the dates Before and After follows:
Note I require DD/MM/YYYY format
Note some cells have " - -"
BEFORE
- -
- -
1/11/2004
18/10/2004
10/08/2004
15/12/2004
10/12/2004
13/12/2004
12/11/2004

AFTER
- -
- -
11/01/2004
18/10/2004 PROBLEM
8/10/2004 PROBLEM
15/12/2004
12/10/2004 PROBLEM
13/12/2004
11/12/2004 PROBLEM

The problem:
If DD < 12 the the format changes from DD/MM/YYYY to MM/DD/YYYY

PS if I copy and paste the data manually I don't get the problem.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Dates Format changing when copying data between workbooks

Thanks William,
I've tested the idea and it works. I'll adapt your code tomorrow to
suit.
Peter

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing dates to date format Tigerxl Excel Discussion (Misc queries) 5 April 3rd 09 10:26 PM
copying info from one cell to another, changing the format, but leaving the number herosuper Excel Worksheet Functions 1 August 27th 06 06:13 AM
Dates keep changing to US format when mail merging SEAN DI''''ANNO Excel Discussion (Misc queries) 0 October 13th 05 04:30 PM
Copying worksheet but changing format Glissader Excel Discussion (Misc queries) 1 June 3rd 05 05:07 PM
copying workbooks with charts and changing data uriel78 Charts and Charting in Excel 1 March 11th 05 02:00 AM


All times are GMT +1. The time now is 05:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"