Elite Membership

Recording Macros in Excel

Written by Vidya Subbu Vidya Subbu Excel Content Writer & Editor Vidya, a former software engineer turned seasoned content writer with 7+ years of experience, excels in creating engaging content. As an editor at WallStreetMojo, she dreams of publishing her own book. 7+ years of experience B.E. (Electronics and Instrumentation) MS Excel - Basic and Advanced View Full Profile
Reviewed by Dheeraj Vaidya, CFA, FRM Dheeraj Vaidya, CFA, FRM Content Reviewer & Course Director Dheeraj is a former J.P. Morgan and CLSA Equity Analyst with nearly two decades of experience in financial modeling, valuation, equity research, and corporate finance. He specializes in helping students and professionals develop practical and in-demand finance skills through structured and AI-powered, 20+ Years of experience CFA, FRM, IIT Delhi, IIM Lucknow Financial Modeling View Full Profile
Updated May 2, 2025
Read Time 5 min

How To Record A Macro In Excel?

Recording macros in Excel helps automate repetitive tasks by capturing the users actions and converting them into VBA code. This feature is useful for users with very little programming experience. In a few clicks, one can create a macro that performs tasks as it is done manually.

Recording Macros in Excel
Download FREE Recording Macros Excel Template and Follow Along!
Download Excel Template

To record a macro in Excel, either the View tab or the Developer tab can be used, as shown in the following images.

excel macros example 1
excel macros example 1-1

Let us consider anย example to understand the steps to create an Excel macro.

The following table contains the overall grades of students. The report is to be formatted on a daily basis. We need to perform tasks like applying borders, highlighting headers, setting background colors, and so on.

We want to record a macro for these repetitive tasks.

excel macros example 1-2

The steps to be performed for recording macros are listed as follows:

  • Step 1:ย In the Developer tab, select โ€œRecord Macroโ€ under the โ€œCodeโ€ section.


    excel macros example 1-3

  • Step 2: The โ€œRecord Macroโ€ dialog box opens, as shown in the following image. In โ€œMacro name,โ€ enter โ€œFormatting.โ€

    Note: It should be ensured that no space is entered while naming the macro.

    excel macros example 1-4

  • Step 3:ย In โ€œshortcut key,โ€ assign the shortcut key โ€œFโ€ to the macro. This shortcut runs the macro.


    excel macros example 1-5

  • Step 4: In โ€œStore macro in,โ€ select โ€œThis Workbook.โ€ With this selection, the macro is stored in the present workbook. Moreover, this macro will work only in the current workbook.


    excel macros example 1-6

  • Step 5: In โ€œDescription,โ€ type what the macro intends to do.


    excel macros example 1-7

  • Step 5: Click โ€œOKโ€ and the โ€œrecord macroโ€ option changes to โ€œStop Eecordingโ€ under the โ€œCodeโ€ group.


    excel macros example 1-8

  • At this time, the actions we perform are recorded in the macro. To ensure that the automated tasks are executed every time a new range is selected, activate โ€œuse relative references.โ€ This is done prior to creating the macro.


    example 1-9

Once the steps of formatting like applying borders, highlighting headers, setting background colors, etc., have been recorded, click โ€œstop recordingโ€ (shown in the sixth point).

Apply recorded formatting with the help of the shortcut key โ€œCtrl+Shift+F.โ€ The output is shown in the following image.

Key Takeaways

  • Macros help automate repetitive tasks in Excel by recording your actions.
  • You can record a macro through the Developer tab without needing to write code.
  • Always save the workbook as a macro-enabled file with the .xlsm extension to retain the macro.

Using Recorded Macros

There is another table containing the grades of students. It has to be formatted in the same way the data of Example #1 was formatted.

example 1-11

Select A1 and press โ€œCtrl+Shift+Fโ€ for formatting the selected cells. Hence, custom formatting is applied in one go without carrying out multiple commands.

example 1-12

The limitation of the macro recorder is that it is full of unnecessary codes.

How To Run A Recorded Macro?

To run a recorded macro in Excel, there are a few ways

1. Go to the Developer tab and click on Macros.ย 

In the dialog box that appears, select the macro name you want to run, then click Run.ย 

How To Run A Recorded Macro

2. You can also assign the macro to a button or shortcut key as shown above for easier access.

How To Save Macros In Excel?

When one has recorded a macro or written one manually, we have to save theย  workbook as macro enabled with a .xlms extension.ย 

Follow the below steps:

  1. After recording the macro, click File -> Save As.
  2. In the “Save as type” dropdown, select Excel Macro-Enabled Workbook (*.xlsm).
How To Save Macros In Excel

3. Choose the desired location and click on Save.

The Cautions While Recording A Macro

The following points must be remembered while recording a macro:

  • The file containing macros must be saved with the โ€œ.xlsmโ€ extension.
  • While downloading an Excel file with the โ€œ.xlsmโ€ extension (macro-enabled workbook), it should be ensured that the source is authentic.
  • The โ€œauto sumโ€ function should not be used while creating a macro because it hard codes the formula.
  • The formula should be typed with a single dollar sign like โ€œ=SUM(E$2: E10).โ€ The macro recorder records E$2 as a fixed reference and begins the SUM directly below the โ€œrow 1โ€ headings. It recognizes E10 as a relative reference and points directly above the current active cell E11.

Frequently Asked Questions (FAQs)

What does recording macros in Excel mean?

To avoid doing repetitive tasks again and again, Excel provides a way of automating them. The steps like cell formatting, number formatting, saving workbooks, deleting worksheets, importing data, and so on are recorded as macros.

A macro is created using the macro recorder and can be replayed whenever required. The macro can be run, edited, copied (in another workbook), assigned (to a button or object), enabled, and disabled. The Excel macro code can be viewed and edited in Visual Basic Editor (VBE).

Give some tips to record macros in Excel.

The tips on recording macros in Excel are listed as follows:

  • Relative referencing must be activated to ensure that the macro works with new selections.
  • GO ahead with recording macros in Excel only if you are familiar with the steps. If the shortcut key โ€œCtrl+Zโ€ is pressed, it is recorded. So, a smooth recording is essential for running the macro efficiently.
  • A backup of the workbook must be created before running a macro. This helps prevent unwanted changes to the current file.
  • Instead of a large macro, create several short ones. This is because shorter macros are easy to understand and allow error-free recording.
What are absolute and relative references while recording macros?

The two references are explained as follows:

  • If a macro is recorded using absolute references, the VBA code will always refer to the same cell selection. This selection is used every time a macro is run, irrespective of the current active cell. For instance, cell A2 is selected, text โ€œhelloโ€ is typed, and the โ€œenterโ€ key is pressed. The code will always begin by selecting cell A2.
  • If a macro is recorded using relative references, the VBA code will record the movement rather than the exact cell selection. Working on the preceding example, if cell K2 is selected, Excel will move relative to cell K2. So, Excel will not work on cell A2.

Note: By default, a macro is recorded using absolute references

Recommended Articles

This has been a guide to Record a Macro in Excel. Here we learn how to create a Macro in Excel along with Excel example and downloadable Excel templates. You may also look at theseย useful functions of Excel โ€“