Copy Cells

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

After importing rows into Excel, I need to copy the values only of column P
into the same row in column AA, but only if column P has not yet been copied
(only newly appended rows). I've tried many ways unsuccessfully. I'd
appreciate any guidance. Thanks.
 
This might work:

Sub CpyMaybe()
lr = Cells(Rows.Count, 16).End(xlUP).Row
For i = 1 To lr 'Assumes no header, change AR
If Cells(i, 16) <> Cells(i, 27) Then
Cells(i, 16).Copy Cells(i, 27)
End If
Next
End Sub
 
Cells(i, 16).Copy Cells(i, 27)

This line copies and pastes in one action. What other paste do you want to
do.
Maybe I didn't understand the question.
 
Ok, I think I understand the problem now. Try this.

Sub CpyMaybe()
lr = Cells(Rows.Count, 16).End(xlUP).Row
For i = 1 To lr 'Assumes no header, change AR
If Cells(i, 16) <> Cells(i, 27) Then
Cells(i, 16).Copy
Cells(i, 27).PasteSpecial Paste:=xlValues
End If
Next
End Sub
 
Yes, pefect. Thanks so much.

JLGWhiz said:
Ok, I think I understand the problem now. Try this.

Sub CpyMaybe()
lr = Cells(Rows.Count, 16).End(xlUP).Row
For i = 1 To lr 'Assumes no header, change AR
If Cells(i, 16) <> Cells(i, 27) Then
Cells(i, 16).Copy
Cells(i, 27).PasteSpecial Paste:=xlValues
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top