In Excel, copying and pasting data is one of the most common repetitive tasks. A macro can record these actions and repeat them automatically.
Copy and paste means duplicating data from one location to another location without typing the data again.
For example, you can copy data from cells A1:A5 and paste it into cells C1:C5.
A1:A5 → C1:C5
If you repeatedly copy information from one worksheet or range to another, performing the same steps manually can take time.
A macro can record these actions and repeat them whenever required.
Suppose a student list is stored in columns A and B:
A B
Student ID Name
101 Rahul
102 Amit
103 Priya
You may need to copy this information to another report sheet every day. This is a good task for a macro.
Before recording the macro, create some sample data in an Excel worksheet.
For example:
A1 = Student ID
B1 = Student Name
A2 = 101
B2 = Rahul
A3 = 102
B3 = Amit
The Macro Recorder is available from the Developer tab.
Click the Developer tab on the Excel Ribbon.
If the Developer tab is not visible, enable it from Excel Options.
Click Developer → Record Macro to start recording.
Excel will open the Record Macro dialog box.
Give your macro a meaningful name.
For example:
CopyStudentData
A meaningful name makes it easier to identify the macro later.
In the Record Macro dialog box, you can choose where the macro will be stored.
For normal practice, you can store the macro in the current workbook.
Select This Workbook if you want the macro to belong to the current Excel file.
After clicking OK, Excel starts recording your actions.
Select the cells that you want to copy.
For example:
Select A1:B3
The selection itself becomes part of the recorded actions.
After selecting the data, use the Copy command.
You can use:
The Macro Recorder records the action you perform.
After copying the data, select the cell where you want to paste it.
For example:
Select D1
This tells Excel where the copied data should be placed.
Now paste the copied data into the destination location.
You can use:
The paste action is also recorded by the Macro Recorder.
A macro can also record copying data from one worksheet to another worksheet.
For example:
Sheet1 → Copy Data → Sheet2 → Paste Data
This is useful when preparing reports from existing data.
You can record the copying of an entire table.
For example, select A1:F20, copy it, and paste it into another area.
A1:F20 → Copy → H1 → Paste
The macro can repeat the same operation later.
After completing the copy and paste operation, stop the Macro Recorder.
Go to:
Developer → Stop Recording
Your macro is now created.
You can run the recorded macro from the Macros dialog box.
Go to:
Developer → Macros
Select your macro and click Run.
When the macro runs, Excel repeats the recorded copy and paste actions.
For example, if the macro recorded copying A1:B3 and pasting it into D1, Excel attempts to repeat those actions.
Normal copy and paste can also copy formatting along with the cell contents.
For example, if the original cells contain bold text, borders, and fill colors, normal copy and paste can reproduce those formatting elements.
The recorded macro can repeat the same operation.
Sometimes you may want to copy only the displayed values instead of formulas or formatting.
Excel provides Paste Values for this purpose.
A recorded macro can also record a Paste Values operation when you perform it during recording.
The Macro Recorder creates VBA code behind the scenes.
You can view this code by opening the VBA Editor.
Use:
Developer → Visual Basic
Then open the module containing your recorded macro.
A recorded copy operation may produce VBA code similar to:
Range("A1:B3").Select
Selection.Copy
Range("D1").Select
ActiveSheet.Paste
The exact code can vary depending on the actions and Excel version.
Copy and paste macros are useful for moving information from one worksheet to another.
For example:
StudentData → Report
This can be useful when creating daily or monthly reports.
A recorded macro usually repeats the specific actions that were recorded.
If the data size or location changes, the recorded macro may not automatically understand the new situation.
Dynamic copy and paste operations can later be created using VBA programming.
Copy and paste macros are commonly useful for report preparation.
For example, you can:
Suppose you maintain student information in a worksheet called StudentData.
You want to copy the student table to a worksheet called Report.
The recorded workflow can be:
StudentData
↓
Select Student Table
↓
Copy
↓
Report
↓
Paste
While recording copy and paste macros:
A basic workflow is:
Prepare Data
↓
Developer Tab
↓
Record Macro
↓
Select Data
↓
Copy
↓
Select Destination
↓
Paste
↓
Stop Recording
↓
Run Macro
The Macro Recorder is useful for learning and automating simple copy and paste tasks.
VBA programming provides more control when you need dynamic ranges, conditions, loops, or more complex automation.
Therefore, learning the Macro Recorder is a useful first step before learning advanced VBA automation.
Try the following exercise:
This exercise will help you understand how Excel records copy and paste operations.
A copy and paste macro records the process of selecting data, copying it, selecting a destination, and pasting it.
Once recorded, the macro can repeat those actions automatically.
This is especially useful for repetitive data movement and report preparation.
Select → Copy → Destination → Paste → Repeat Automatically
Question: What does a copy and paste macro mainly automate?