Date format chaging when copying sheet from another workbook

harshad_agashe

New Member
Joined
Jul 31, 2002
Messages
2
Hi,

(its nice to see mrexcel forum still active. last time I used it was in 2002 ! )


I am trying to open a different workbook and copy one of sheets data to current sheet. It works, but date stored as "1/11/2013" is chaging to "11/1/2013". (if the date is "23/9/2013", its getting copied correctly. probably because background format conversion does't produce valid date).

The copy of the sheet works, just the date format changes.

I tried pasteSpecial but didn't help.

Macro is as below.


Sub read_file()
Dim oWB As Workbook
Dim x_rrc_extract As String


x_rrc_extract = "C:\Temp\rrc_extract.xlsx"
Set oWB = Workbooks.Open(x_rrc_extract)


'Original code to copy paste sheet
With ActiveSheet
.Range(.Cells(1, 1), .Cells.SpecialCells(xlCellTypeLastCell)).Select
End With

Range(Selection, Cells(1)).Select
Selection.Copy


Application.DisplayAlerts = False
oWB.Close
Application.DisplayAlerts = True



' pasting the selection from source sheet to the target
Windows("Book1.xlsm").Activate
Sheets("Sheet1").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.Save

'New code added on 3/Sep to take control to first sheet
Sheets("Sheet1").Select
Range("A1").Select
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,216,604
Messages
6,131,700
Members
449,666
Latest member
Tommy2Tables365

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top