Get the Copy Data Macro Workbook
The macro-enabled workbook from the video. It has the summary sheet, the two data sheets and the finished Copy_Data macro with its button, so you can test it and read the code.
The workbook contains macros. Excel blocks macros in files downloaded from the internet, so right-click the file, choose Properties, tick Unblock and click OK before you open it.
Absolute vs. Relative Macro Recording
The macro recorder has two modes, and the difference decides whether your macro works next week.
- Absolute recording (the default) writes down the exact cell you clicked, like
Range("A9"). The macro goes to A9 every time, even when your data has grown. - Relative recording writes down how far you moved from the active cell, like
ActiveCell.Offset(1, 0). The macro repeats the same movement from wherever it starts.
Neither mode is right on its own. A dynamic macro needs a mix of both. New to macros? Start with how to record your first macro.
Where to Find the Use Relative References Toggle
Go to the Developer tab. Under Record Macro, click Use Relative References. When the button has a dark gray background, relative recording is on. Click it again to go back to absolute recording.
No Developer tab? Right-click the ribbon, choose Customize the Ribbon, and tick Developer.
How to Find the Next Empty Row with the Macro Recorder
To add new data below an existing list, the macro has to find the first empty row. The usual keyboard way is to click the header, press Ctrl+Down Arrow to jump to the last row, and move one cell down. Here is how each recording mode writes that down.
Absolute Recording
Range("A3").Select
Selection.End(xlDown).Select
Range("A9").SelectThe first two lines are fine. The last line is the problem. The recorder fixed the result to A9, so once you add more rows, the macro still lands on A9 and pastes over your data.
Relative Recording
ActiveCell.Offset(-1, -1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").SelectNow the last line is right. Offset(1, 0) means one row down and zero columns across, so it always lands on the next empty row. The .Range("A1") part is something the recorder adds. It just means one cell, and you can delete it.
But the first line is now a problem. It moves one row up and one column left from wherever you happen to be. Start the macro from a different cell, and it goes to the wrong place or stops with an error.
Combine Both Modes
The fix is to switch modes while you record:
- Record the click on the header cell in absolute mode, so the macro always starts there.
- Press Ctrl+Down Arrow. This step records the same way in both modes.
- Turn on Use Relative References, move one cell down, and turn it off again right away.
How to Record a Macro That Copies Data to Another Sheet
In the example, new data arrives on two sheets, NewData#1 and NewData#2. The macro copies both blocks to the bottom of the list on the SummaryData sheet.
- Make sure Use Relative References is off, then click Record Macro and name it Copy_Data.
- Go to the NewData#1 sheet and click A4, where the data starts.
- Press Ctrl+Shift+Down Arrow, then Ctrl+Shift+Right Arrow to select the whole block, and press Ctrl+C.
- Go to the SummaryData sheet, click the header cell A3 and press Ctrl+Down Arrow.
- Turn on Use Relative References, press the Down Arrow once, and turn it off again.
- Press Ctrl+V to paste.
- Repeat steps 2 to 6 for the NewData#2 sheet.
- Click A3 so the macro ends at the top of the list, then click Stop Recording.
This is the code the recorder writes. The two relative steps are the ActiveCell.Offset(1, 0) lines.
Sub Copy_Data()
Sheets("NewData#1").Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("SummaryData").Select
Range("A3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("NewData#2").Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SummaryData").Select
Range("A3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Range("A3").Select
End SubSave the file as an Excel Macro-Enabled Workbook (.xlsm). A normal .xlsx file deletes the macro when you save it.
How to Add a Button to Run the Macro
- On the Developer tab, click Insert and choose the Button under Form Controls.
- Draw the button on the SummaryData sheet.
- In the Assign Macro dialog, pick Copy_Data and click OK.
- Right-click the button, choose Edit Text, and give it a clear label such as Copy Data Over.
Click the button, and both blocks appear below your list. Click it again, and they are added below that.
Make the Macro More Reliable
The recorded macro works, but it has one weak spot. Ctrl+Down Arrow from the header only works when there is at least one row of data below it. On an empty list, it jumps to the last row of the sheet, and the offset has nowhere to go.
Once you are comfortable in the VBA editor, you can find the next empty row from the bottom of the sheet instead, and copy without selecting anything:
Sub Copy_Data_Clean()
Dim src As Variant
Dim lastRow As Long, lastCol As Long, nextRow As Long
For Each src In Array("NewData#1", "NewData#2")
With Worksheets(src)
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
lastCol = .Cells(4, .Columns.Count).End(xlToLeft).Column
If lastRow >= 4 Then
nextRow = Worksheets("SummaryData").Cells(Rows.Count, "A").End(xlUp).Row + 1
.Range(.Cells(4, 1), .Cells(lastRow, lastCol)).Copy _
Destination:=Worksheets("SummaryData").Cells(nextRow, "A")
End If
End With
Next src
End SubCells(Rows.Count, "A").End(xlUp) starts at the very last row and jumps up to the last filled cell. That works on an empty summary list and on a data sheet with only one new row, two cases where Ctrl+Down Arrow fails.
Do you combine the same kind of files or sheets every month? Then Power Query can combine them without any code, and a refresh pulls in the new data.
This tutorial is part of the Unlock Excel VBA & Excel Macros course, which goes from beginner to advanced.
Featured Course
Unlock Excel VBA & Excel Macros

Download the Workbook
Download the Copy Data Macro Workbook
The .xlsm file from this tutorial with the recorded macros and the button.
Frequently Asked Questions
What is the difference between absolute and relative macro recording?
Absolute recording saves the exact cells you click, so the macro always goes to the same address. Relative recording saves how far you move from the active cell, so the macro repeats the same movement from wherever it starts.
Where is the Use Relative References button in Excel?
It is on the Developer tab, right under Record Macro. If you do not see the Developer tab, right-click the ribbon, choose Customize the Ribbon and tick Developer.
How do I copy data to the next empty row with VBA?
Find the last filled row from the bottom of the sheet with Cells(Rows.Count, 1).End(xlUp).Row and add 1. Then copy the source range and use that row as the destination.
Why does my recorded macro paste over existing data?
It was recorded in absolute mode, so the paste cell is fixed, for example A9. Record the step that moves to the empty row with Use Relative References turned on, or find the next empty row in the code.
Why are the macros disabled when I open the workbook?
Excel blocks macros in files downloaded from the internet. Close the file, right-click it, choose Properties, tick Unblock and click OK. Then open it again and enable the content.
Do I need to save the file as an .xlsm workbook?
Yes. A normal .xlsx workbook cannot store macros, so Excel removes them when you save. Save the file as an Excel Macro-Enabled Workbook to keep the code.
Leila Gharani
Founder of XelPlus and ten-time Microsoft MVP. Leila helps over 500,000 professionals master Excel, Power BI, and data automation through practical, real-world training.








