Microsoft Office Macro Recorder: How It Works

VBA & macros · Updated November 3, 2026

Microsoft Office Macro Recorder: How It Works

Microsoft Office has macro recorders in desktop Excel and Word; in Excel for Microsoft 365 on Windows, choose View > Macros > Record Macro, or Developer > Code > Record Macro, perform the actions you want to automate, and then stop recording. The recorder converts supported actions into VBA code; Excel for the web cannot record or run VBA macros.

What the Office macro recorder does

A macro is a saved sequence of instructions that can repeat work in an Office application. The recorder observes certain commands and interactions, then writes them as Visual Basic for Applications, or VBA. You can run the resulting macro again, assign it to a keyboard shortcut or button, and inspect or adjust its code in the Visual Basic Editor.

People asking about the Microsoft Office macro recorder usually mean Excel’s recorder. It is useful for repetitive spreadsheet work such as applying the same number format, creating a standard report layout, or cleaning a consistently structured table. Word also has a macro recorder for some document operations. Office does not provide one universal recorder that captures activity across every application: for example, PowerPoint does not have a built-in macro recorder.

Recording is not the same as teaching Office to understand a general task. The recorder reproduces a sequence of supported operations. It does not infer that you want to process every future file, decide what counts as an error, or adapt intelligently when a worksheet changes shape. Those requirements may call for editing VBA or using another automation tool.

How to record a macro in Excel

Before recording, open a copy of the workbook and decide which actions should be repeated. In Excel for Microsoft 365 on Windows, use either View > Macros > Record Macro or Developer > Code > Record Macro. If the Developer tab is missing, turn it on under File > Options > Customize Ribbon by selecting Developer.

  1. Enter a short macro name in the Record Macro dialog. Macro names cannot contain spaces; use a name such as FormatMonthlyReport.
  2. Choose where to store it. This Workbook keeps it with the open workbook, Personal Macro Workbook makes it available in Excel on that computer, and New Workbook stores it in a separate workbook.
  3. Optionally assign a shortcut and add a description. Avoid choosing a shortcut that you rely on for a standard Excel command.
  4. Carry out only the actions you want the macro to repeat. For example, select a report range, apply a number format, bold the header row, and set column widths.
  5. Choose View > Macros > Stop Recording, or use the Stop Recording control on the status bar if it is displayed.

Try the macro on a duplicate or a disposable sample before relying on it. A recorded macro often acts on the active sheet, selected cells, or specific addresses from the recording session. If you start it while the wrong sheet or range is active, it may affect the wrong data.

Absolute and relative references

One important setting determines how Excel records cell selection. With the default absolute-reference behavior, recording a selection of cells such as A1:B10 generally preserves those addresses. Running the macro later may select that same range even if you began in another cell. This can be appropriate for a fixed template but surprising when applying a routine to a new block of data.

For actions that should be relative to the current selection, select Developer > Code > Use Relative References before recording. For example, you might want a macro to format the header row directly above the current data row rather than always formatting row 1. The setting changes how recorded navigation is represented; it does not make every part of a macro automatically flexible. Check the result in the Visual Basic Editor and test it from different starting cells.

For a reusable process, consider whether a macro should use the current selection, a named range, or a fixed worksheet address. These choices affect whether it works when rows are inserted, the active sheet changes, or the source data grows. The recorder makes an initial version, but reliable automation often benefits from a small amount of review.

What the recorder can and cannot capture

The recorder is strongest when the task is a predictable sequence of commands. It can capture many common worksheet operations, including selecting cells, entering values or formulas, changing formatting, and using ribbon commands. A recorded formatting routine, for instance, can apply a header style, set date formatting, and freeze a chosen pane.

It does not capture every kind of work. The recorded procedure may not include the logic needed to make decisions, find an unknown last row, handle missing values, or repeat an action for each item in a list. Some actions or interface features are not recordable, and recorded steps may depend on the exact selection and workbook layout used at the time. A macro that works on a sample sheet can therefore fail or produce an unwanted result on a differently arranged sheet.

Macros also do not record mouse movement as a video. They store instructions for actions that Excel can express in VBA. If you make mistakes while recording, stop and record again or edit the generated code; the recorder is not a general undo history. For complex conditions, loops, error handling, or interaction with files and other applications, a person familiar with VBA may need to write or revise code.

Saving and sharing recorded macros

Excel workbooks saved as .xlsx cannot contain VBA macro code. To keep a macro in the workbook, save it as an Excel Macro-Enabled Workbook (.xlsm), or use another macro-capable format such as .xlsb where appropriate. Excel may warn that a macro-free format cannot retain the VBA project; choosing to remove the code means it will not be available when the file is reopened.

If you chose Personal Macro Workbook, Excel stores the macros in a hidden workbook that opens when Excel starts on that computer. That can make a personal utility available across workbooks, but it does not automatically travel with a file you send to someone else. A macro saved in This Workbook is more portable with that workbook, though recipients still need a desktop version of Excel that can run VBA and must be permitted to use the file.

When sharing a macro-enabled workbook, explain what the macro does and provide the source file through a trusted channel. Recipients should not enable macros simply because a document asks them to. If another person needs to review the procedure, the Visual Basic Editor can display the VBA project, subject to any project protection set by its author.

Editing, running, and troubleshooting

To see recorded macros in Excel, choose View > Macros > View Macros, select one, and choose Edit to open its VBA code. You can also use the Developer tab’s Code group to open the Visual Basic Editor. To run a macro from the dialog, choose View > Macros > View Macros, select the macro, and choose Run. A button or keyboard shortcut can make a frequently used macro easier to launch.

When a macro behaves incorrectly, first check that it is stored in the workbook or Personal Macro Workbook you expect, that the workbook is macro-enabled, and that you started it from the intended sheet and cell. Look for references to a fixed sheet name or cell address. If the workbook’s structure changed after recording, steps that select ranges or refer to particular columns may no longer match the data.

Macros cannot be undone with Ctrl+Z. Save a separate copy before running one, especially when it edits, deletes, or reformats data. If an unexpected result occurs, close the test copy without saving rather than assuming Excel’s Undo command can reverse the macro.

Which Office apps have a recorder?

Excel’s recorder creates VBA macros, and desktop Word also includes a recorder for supported document actions. In Word, the recorded procedure can help with repeated formatting or editing tasks, but its instructions can be sensitive to the document’s selection and structure. The available recording options and interface can differ between Windows and Mac versions, so follow the commands shown in the installed desktop app.

PowerPoint does not include a built-in macro recorder. It can run VBA macros, but those generally need to be written or obtained as code rather than captured through a recorder. Outlook and other Office applications likewise have their own automation capabilities and limitations; the presence of VBA support in an application does not mean that it has an equivalent recorder.

On Mac, desktop Excel supports VBA macros and macro recording, although ribbon layouts, dialogs, and some available features differ from Windows. Excel for the web is different: it can open and edit many workbook types, but it does not create, run, or edit VBA macros. A workbook containing VBA may still be opened there, but the VBA procedure will not run in the browser.

Security and safer alternatives

VBA macros can change files and data, so treat them as executable code rather than harmless spreadsheet content. Microsoft 365 security settings may block macros in files downloaded from the internet, and an organization can impose stricter policies. Do not weaken security settings or enable all macros to make an unfamiliar file work. If a macro is expected, confirm its origin and purpose with the sender or your organization’s IT team.

For routine automation in Excel, Office Scripts may be a better fit when the feature is available in your account and environment. Scripts use TypeScript rather than VBA, and supported versions of Excel include an Automate tab with tools such as Record Actions. The Action Recorder can turn some spreadsheet interactions into an Office Script, but Office Scripts and VBA are distinct technologies: scripts are not simply another way to save a VBA macro, and their availability depends on platform, account, and organizational settings.

For very simple repeated tasks, Excel features such as table formatting, templates, conditional formatting, or built-in data tools may remove the need for a macro. Choose the simplest option that meets the requirement. A recorder is a convenient starting point when the task is a repeated sequence of supported actions, not a guarantee that the resulting automation will suit every workbook.

Frequently Asked Questions

Is there a macro recorder in Microsoft Office?
Yes, desktop Excel and Word include macro-recording features for supported actions. Excel is the application most commonly associated with the Office macro recorder. There is no single recorder that works across all Office apps, and PowerPoint has no built-in macro recorder.

Can I record an Excel macro in the browser?
No. Excel for the web cannot record, run, or edit VBA macros. Use desktop Excel for VBA, or consider Office Scripts if the Automate features are available for your account and task.

Where does Excel save a recorded macro?
You choose the location in the Record Macro dialog: This Workbook, Personal Macro Workbook, or New Workbook. A macro saved in the current workbook requires a macro-capable format such as .xlsm if you want to preserve the VBA code.

Can I change what a recorded macro does?
Yes. Open View > Macros > View Macros, select the procedure, and choose Edit to inspect its VBA code. Editing can make it more flexible, but save a copy and test changes carefully because macros can modify data and cannot be undone with Ctrl+Z.

Why does my macro select the same cells every time?
It was likely recorded using absolute references, which preserve the original addresses. Use Developer > Code > Use Relative References when recording actions intended to move relative to the current selection, then test the macro from more than one starting point.

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.