Link to home
Start Free TrialLog in
Avatar of EdLB
EdLB

asked on

VBA changes part numbers when copying

I have a list of part numbers and two of them give me trouble when copying using vba.

The part numbers:
6000-18-1
6000-18-2

get converted to
8/1/6000
8/2/6000

when using the code below to copy parts from ws1 to ws2

Worksheets("ws1").Activate
Range(Cells(2, 1), Cells(LastRow, 1)).Copy
 
Worksheets("ws2").Activate
Range(Cells(2, 1), Cells(LastRow, 1)).PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False


I tried to format column 1 in ws2 as text (Range("A1").EntireColumn.NumberFormat = "@") before doing the paste but that gives me an error.

Help please..
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of EdLB
EdLB

ASKER

Thanks David. That's pretty simple. Not sure why the PasteSpecial comand I was using changed the number format. The following worked successfully:
 
      Worksheets.("ws1"). Range(Cells(2, 1), Cells(EndRow, 1)).Copy
      Worksheets("ws2").Activate
      Range("A2").Select
      ActiveSheet.paste