Question on Macros

  • Thread starter Thread starter Juan Carlos
  • Start date Start date
J

Juan Carlos

I have a macro that is moving data from on sheet to another.

For example the macro below will move everything that is in l51down to n2.

Sheets("sheet1").Range("l51:l" & Trim(Str(20 + iRows))).Copy
Sheets("sheet3").Range("n2:n" & Trim(Str(3 + iRows))).PasteSpecial
Paste:=xlPasteValues

How can I move more data to sheet 3 that will automatically put the data in
the last row where the previous data was placed?

Thanks
 
I think you mean the first empty row? Either put the data in LastRow or
NewRow.

with Sheets("Sheet3")
LastRow = .Range("n" & Row.Count).end(xlup).row
NewRow = LastRow + 1
Sheets("sheet1").Range("l51:l" & Trim(Str(20 + iRows))).Copy
.Range("n2:n" & NewRow).PasteSpecial
Paste:=xlPasteValues
 
Dim DestCell as range

With worksheets("Sheet3")
set destcell = .cells(.rows.count,"N").end(xlup).offset(1,0)
end with

worksheets("sheet1").range("L51:L" & 20 + irows).copy
destcell.pastespecial paste:=xlpastevalues

(VBA is very forgiving. You don't need the trim(str()) stuff.)
 
Back
Top