I am trying to copy paste two columns from one sheet to another but running the code copies old value to adjacent cell if I run the VBA code more than 1 time
Sub CopyData()
Dim i As Integer
i = Worksheets("SP_Download").Cells(Rows.Count, 6).End(xlUp).Row
If i = 1 Then i = 2
Worksheets("SP_Download").Range("F2:F" & i).Delete
i = Worksheets("DataPull").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("DataPull").Range("A2:A" & i).Copy
Worksheets("SP_Download").Range("F2:F" & i).PasteSpecial Paste:=xlPasteValues
i = Worksheets("SP_Download").Cells(Rows.Count, 6).End(xlUp).Row
Worksheets("SP_Download").Range("I2:I" & i).Delete
i = Worksheets("DataPull").Cells(Rows.Count, 5).End(xlUp).Row
Worksheets("DataPull").Range("E2:E" & i).Copy
Worksheets("SP_Download").Range("I2:I" & i).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub
Intended Data pull after successful code run is this:
but I end up getting this:
Here data gets incorrectly copied to column G & H incorrectly. Can you please help me figure out why this is happening
Thanks