Copy data from the last row from a sheet to another sheet using a macro in an excel report

This simple code is just to copy a data from a sheet and to paste them in another sheet but before that, it will find the last row with value so it will paste the data to the next row, the empty one.

macro excel
macro excel
macro excel

 

When I use the macro ?

To copy a data from a sheet then to paste it to another sheet from the first empty cell.

 

How to create the macro ?

Read How to create, edit, hide and select a macro in an excel report

 

How to create the button to associate it with the macro ?

Read How to create a button and associated it to a macro in an excel report

 

How is the macro ?

Copy the code below and paste it into your macro. You will see my comments in green if exist so follow the help to adapt to your need. This one should be run from Sheet1 (the sheet where to paste):

Sub test()
Dim LastRow As Long
' change Sheet1 by your sheet name where to paste
LastRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
' change Sheet2 by your sheet name where to copy and Sheet1 by the same name to paste
' change A2:D5 by your cell reference to copy
Sheets("Sheet2").Range("A2:D5").Copy Sheets("Sheet1").Cells(LastRow, 1)
End Sub

This one should be run from Sheet2 (the sheet where to copy):

Sub test()
Dim LastRow As Long
Dim rng As Range
' change Sheet1 by your sheet name where to paste
LastRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
Set rng = ActiveSheet.UsedRange
Set rng = rng.Offset(1).Resize(rng.Rows.Count - 1)
rng.Select
rng.Copy Sheets("Sheet1").Cells(LastRow, 1)
End Sub

Interesting Management