Paste values changing dates from 2017 to 2018

stroffso

Board Regular
Joined
Jul 12, 2016
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi All
I have a piece of code which simply copies data from all cells in one workbook and pastes it into a table in another. However I am finding that one column (Column N) which is in a "MMM-YY" format keeps changing the Year part from 17 to 18 when it paste values over. On the raw file all of column N has "Apr-17" but when it pastes over it comes up as "Apr-18", Has anyone come across this before?

Below is the code I am using for this




With ActiveSheet.UsedRange
LastRow = .Rows(.Rows.Count).Row
End With


Range("A2:N" & LastRow).Select
Selection.Copy
ThisWorkbook.Activate


ColumnA = Range("A10000").End(xlUp).Row + 1
ColumnB = Range("B10000").End(xlUp).Row + 1
ColumnC = Range("C10000").End(xlUp).Row + 1
ColumnD = Range("D10000").End(xlUp).Row + 1
ColumnE = Range("E10000").End(xlUp).Row + 1
ColumnF = Range("F10000").End(xlUp).Row + 1
ColumnG = Range("G10000").End(xlUp).Row + 1
ColumnH = Range("H10000").End(xlUp).Row + 1
ColumnI = Range("I10000").End(xlUp).Row + 1
ColumnJ = Range("J10000").End(xlUp).Row + 1
ColumnK = Range("K10000").End(xlUp).Row + 1
ColumnL = Range("L10000").End(xlUp).Row + 1
ColumnM = Range("M10000").End(xlUp).Row + 1
ColumnN = Range("N10000").End(xlUp).Row + 1
PasteRow = WorksheetFunction.Max(ColumnA, ColumnB, ColumnC, ColumnD, ColumnE, ColumnF, ColumnG, ColumnH, ColumnI, ColumnJ, ColumnK, ColumnL, ColumnM, ColumnN)
If PasteRow = 4 Then PasteRow = 3

'paste
Range("A" & PasteRow).Select
Selection.PasteSpecial xlPasteValues
Application.CutCopyMode = False

thanks in advance
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Thanks for sending the files over.
The problem comes from copying from a csv file. If you change the Column N dates to the same format as Column C (d-mmm-yy) in the original file it will all copy over okay.

Personally I always try avoid csv.
 
Upvote 0
thanks but Tried that and it doesnt work it still converts them to 2018 dates> I had it before where it worked fine so not sure of how its not working now? Any ideas greatly appreciated

Thanks for sending the files over.
The problem comes from copying from a csv file. If you change the Column N dates to the same format as Column C (d-mmm-yy) in the original file it will all copy over okay.

Personally I always try avoid csv.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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