View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Josh O. Josh O. is offline
external usenet poster
 
Posts: 77
Default Dim & Copy & Paste

I have the below macro to find cells in column 14 and paste them to column
"A", same row, if there is data in that cell.

I need to be able to do the same thing for another column in the same
worksheet (ie - find values in 16th column and paste to same row column "I"),
but I get an error if I try to use similar code (just changing the column
index and destination column).

Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 14).End(xlUp).Row
For i = lastrow To 2 Step -1
If Cells(i, 14) < "" Then
Application.CutCopyMode = False
Cells(i, 14).Copy
Range("a" & Cells(i, 14).Row).Select
ActiveSheet.Paste
End If
Next