Microsoft Excel Record Macro: Steps, Uses, and Limits

VBA & macros · Updated November 3, 2026

Microsoft Excel Record Macro: Steps, Uses, and Limits

To record a macro in Microsoft Excel for Microsoft 365 on Windows, select Developer > Code > Record Macro, perform the actions you want to automate, then select Developer > Code > Stop Recording. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if it needs to keep the recorded macro.

What an Excel macro recorder does

A macro is a saved sequence of instructions that can repeat work in Excel. Excel’s macro recorder observes many commands you perform in the workbook and translates them into Visual Basic for Applications (VBA) code. You can run the saved macro later instead of repeating those actions manually. This is useful for routine formatting, preparing reports, applying a consistent layout, or carrying out a predictable series of edits.

The recorder is best understood as an assistant for creating basic VBA, not as a tool that can capture every kind of work. It records many menu commands and cell operations, but it does not understand the purpose behind them. For example, it may record selecting a particular range rather than identifying a changing block of data by its meaning. That distinction matters when you reuse a macro on a different worksheet or on a larger dataset.

Show the Developer tab first

The Developer tab is where Excel puts the macro recording controls. If it is missing in Microsoft 365 for Windows, enable it from File > Options > Customize Ribbon. In the list of main tabs on the right, check Developer and select OK. This setting adds the tab to the ribbon; it does not change the workbook or enable macros by itself.

On Excel for Mac, open Excel > Settings (called Preferences in some releases) > Ribbon & Toolbar, select the main tabs list, and turn on Developer. The exact wording can vary slightly by release. Once the tab is visible, use Developer > Record Macro to start recording. Excel for the web does not provide the VBA macro recorder; see the alternatives below.

How to record a macro step by step

  1. Open the workbook and, if possible, use a copy while planning the steps. Decide which cells the macro should act on and whether it will be reused with data in a different place.
  2. Select Developer > Code > Record Macro. In the Record Macro dialog, enter a short name that starts with a letter and contains no spaces. You can use underscores to separate words.
  3. Optionally assign a shortcut key. A shortcut can make a frequently used macro quicker to run, but avoid assigning one you rely on for a normal Excel command. Excel indicates the shortcut combination in the dialog.
  4. Choose where to store the macro. This Workbook keeps it with the current file; Personal Macro Workbook makes it available from Excel for future workbooks on that computer; New Workbook stores it in a separate workbook.
  5. If the macro should work from the currently selected starting cell, turn on Use Relative References before recording. Leave it off for actions intended to target the same specific cells each time.
  6. Select OK, then carry out only the steps you want repeated. For example, select a report heading, apply bold formatting and a fill color, then adjust the column widths if those are part of the routine.
  7. When finished, select Developer > Code > Stop Recording. Excel stops capturing actions, and the macro is available through Developer > Macros.

Keep the recording focused. Unnecessary selections, scrolling, or extra formatting commands can become part of the macro and make its behavior harder to predict. If you make a mistake, stop recording and inspect the result rather than continuing with a sequence you do not want to repeat.

Absolute and relative references

One of the most important choices is whether a recording uses absolute or relative references. With relative references off, actions are generally recorded against the specific cells selected during recording. If you format B2, running the macro later may format B2 again, even when your active cell is somewhere else. This can be appropriate for a fixed template or a report with a permanent layout.

With Use Relative References turned on, Excel records actions in relation to the active cell. Suppose you start in A1, move one cell right, and apply a format. A relative recording can repeat that one-cell movement from another starting position. This is more adaptable for repeated blocks, but it does not automatically make a macro smart enough to find the end of any dataset or recognize a particular heading.

For instance, a macro that formats a heading in the first row of each monthly sheet may work well with relative navigation if every sheet has the same layout. If one month has an extra title row, the same movements could format the wrong cells. Match the reference setting to the workbook’s structure, and test the macro on a copy with representative data before relying on it.

Run, review, and edit a recorded macro

To run a macro in the open workbook on Windows, select Developer > Code > Macros, choose its name, and select Run. You can also press Alt+F8 to open the Macro dialog. On a Mac, use Developer > Macros if the Windows shortcut does not apply. If you assigned a shortcut while recording, you can use that combination instead.

To review the generated VBA, open Developer > Code > Macros, select the macro, and choose Edit. Excel opens the Visual Basic Editor, where the recorded procedure appears. The code can reveal why a macro behaves a certain way: it may include selections, movements between cells, and commands corresponding to ribbon actions. Beginners can use this view to learn, but editing VBA requires care; a small change can alter what the macro affects.

A simplified formatting procedure might look like this:

Sub FormatReportHeading()
    ' Keep a reference to the active worksheet.
    Dim ws As Worksheet
    Set ws = ActiveSheet

    ' Apply consistent formatting to the report heading.
    With ws.Range("A1:D1")
        .Font.Bold = True
        .Interior.Color = RGB(217, 225, 242)
    End With
End Sub

This example targets A1:D1 specifically, so it assumes the heading is always in that range. A recorded macro may include more selection and navigation code than this compact example. Before running any macro that you have edited or received from another source, save a copy of the workbook. VBA macro actions cannot be undone with Ctrl+Z, so a backup is the practical way to recover from unintended changes.

Save macros in the right file

A macro stored in the current workbook needs a format that supports VBA. Choose File > Save As and select Excel Macro-Enabled Workbook (*.xlsm). If you save a macro-containing workbook as the standard .xlsx format, Excel warns that VBA code cannot be saved in that file format; keeping the .xlsx copy will remove the macro code from it.

Choose This Workbook when the macro belongs with one particular report or template, especially if you will share that file with colleagues. Choose Personal Macro Workbook when you want a personal utility macro available in Excel across workbooks on your own computer. The Personal Macro Workbook is a separate hidden workbook that Excel opens for you; it is not automatically included when you send someone an ordinary workbook. New Workbook is useful when you want the macro in a separate file, but it also means you must manage and save that file.

Macro security and safe use

VBA macros can make changes to a workbook and, depending on their code and permissions, may interact with files or other resources. Treat a macro-enabled file from an unfamiliar sender with caution. Do not enable macros simply because a workbook asks you to; verify who provided the file and why the code is needed. An unexpected macro is not made safe just because it was created with Excel’s recorder.

On Windows, macro controls are available at File > Options > Trust Center > Trust Center Settings > Macro Settings. The available choices depend on the organization’s policies. In general, avoid enabling all macros for every file. Use Excel’s warnings and your organization’s approved process, and only run code from a source you trust. Work or school devices may be managed by an administrator, who can restrict these settings.

Common problems and limitations

  • The Developer tab is missing: Enable it in ribbon settings as described above. It may be hidden by a customized ribbon or restricted by an organization.
  • The macro did not save: Check that the workbook was saved as .xlsm, or confirm that you selected Personal Macro Workbook if that was your intention. Saving to .xlsx does not preserve VBA.
  • It changes the wrong cells: Check whether recording used absolute or relative references, and confirm the starting cell and worksheet. A fixed cell address may not suit a different layout.
  • The macro runs only on one sheet: Some recorded actions refer to the active sheet or a particular worksheet. Confirm that the intended sheet is active and review the code if the workbook structure varies.
  • It works on one dataset but not another: A recorded sequence often assumes the same columns, starting row, and layout as the original recording. Different data sizes or inserted rows can expose those assumptions.

The recorder also has limits beyond these common issues. It generally captures actions that Excel exposes as recordable commands, not a full description of your intent. It cannot reliably turn every manual decision into a rule, and it is not a substitute for writing or reviewing code when a task needs conditions, error handling, or flexible logic. If the process depends on deciding whether a value meets a rule, a formula, a carefully written VBA procedure, or another automation approach may be more suitable.

Excel for the web and other automation options

Excel for the web can open macro-enabled workbooks, but it cannot create, edit, or run VBA macros. If you need to use an existing VBA macro, open the file in the desktop Excel app. For browser-based automation, Office Scripts are a separate option in supported Microsoft 365 accounts. They use TypeScript rather than VBA, and the Automate tab may offer recording actions in supported environments. Availability depends on the account, administrator settings, and Excel version.

For simpler repeatable tasks, consider whether a macro is necessary. Excel’s built-in features such as tables, filters, sort commands, and conditional formatting may handle a recurring task without code. Power Query can be useful for repeatable data import and transformation, while formulas can calculate results as data changes. These options are not identical to a macro: choose based on whether the need is to repeat interface actions, transform data, or keep calculated results updated.

Frequently Asked Questions

Where is Record Macro in Excel?
On Windows, open Developer > Code > Record Macro. If Developer is not visible, enable it at File > Options > Customize Ribbon. On Mac, enable Developer in Ribbon & Toolbar settings, then use Developer > Record Macro.

How do I stop recording a macro?
Select Developer > Code > Stop Recording. If you do not see the ribbon control, return to the Developer tab and look in the Code group. Stopping the recording ends capture; it does not delete the macro already created.

Can Excel record a macro in the browser?
No. Excel for the web does not record, edit, or run VBA macros. Use the desktop Excel application for VBA, or check whether Office Scripts and the Automate tab are available for your Microsoft 365 account.

Why did my macro disappear after saving?
The workbook may have been saved as .xlsx, which does not retain VBA code. Save a workbook containing macros as .xlsm, or confirm that the macro was stored in the Personal Macro Workbook rather than the current file.

Can I undo a macro with Ctrl+Z?
No. Running a VBA macro clears Excel’s normal undo history, so Ctrl+Z cannot reverse the macro’s changes. Save a separate copy before running unfamiliar or potentially destructive code.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.