Macro Recorder for Automation: What It Can and Can’t Do

VBA & macros · Updated November 8, 2026

Macro Recorder for Automation: What It Can and Can't Do

Yes. Excel for Microsoft 365 on Windows includes a macro recorder that turns many repeated actions into VBA code you can run again. It is useful for predictable, repetitive tasks, but the recording captures clicks and selections rather than understanding your goal, so the result often needs review before it is dependable.

What an Excel macro recorder does

A macro is a saved sequence of instructions. Excel’s recorder observes supported actions you perform in the workbook and writes corresponding Visual Basic for Applications (VBA) code. You can then run that macro to repeat the actions instead of doing them by hand.

For example, you might record applying a heading style, setting column widths, adding borders, and formatting dates in a recurring report. A later run can repeat those formatting operations. The recorder is most helpful when the task is stable, the steps are clear, and the same workbook layout is used repeatedly.

Recording is not the same as describing an objective to Excel. It does not infer that a list should be cleaned or that a report should be prepared. It records actions that Excel can translate into VBA, including some intermediate selections that may not be necessary. That distinction explains both its convenience and its limitations.

How recording works

When recording starts, Excel tracks supported actions and creates a procedure in a VBA module. Actions might include selecting a range, entering text, applying number formats, changing cell colors, or sorting data. The resulting code can refer to specific cells and ranges, or use relative movements depending on the recording setting.

The macro runs against the active workbook and may depend on which sheet or cell is selected. A recorded action can therefore work perfectly in the original situation but fail or affect the wrong cells if the layout, active sheet, or starting position changes. Reviewing the code and testing with a copy helps reveal such assumptions.

Excel does not record every possible interaction. Some actions are unsupported, and interactions outside the workbook—such as work in another desktop application—are not generally captured as reusable Excel VBA steps. The recorder is intended for Excel tasks, not as a universal mouse-and-keyboard automation tool.

Record and run a macro in Excel for Windows

  1. Open the workbook and choose the worksheet or cell that will be the starting point for the task. If the workbook contains important data, save a separate copy before experimenting.
  2. On the ribbon, choose View > Macros > Record Macro. You can also use Developer > Code > Record Macro if the Developer tab is visible.
  3. In the Record Macro dialog, enter a name. Macro names cannot contain spaces; start with a letter and use letters, numbers, or underscores. Choose where to store it. This Workbook keeps the macro with the current file.
  4. Optionally assign a keyboard shortcut or add a description. Avoid a shortcut that you already use, because a macro shortcut can override a normal Excel shortcut while the workbook is open.
  5. Choose OK, then perform the actions you want Excel to record. Work deliberately: extra selections, scrolling, or clicks can create unnecessary code or make the macro depend on a particular starting state.
  6. When finished, choose View > Macros > Stop Recording, or use the Stop Recording control on the status bar if it is displayed.
  7. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if it contains VBA. The standard .xlsx format cannot store VBA macros.

To run it, use View > Macros > View Macros, select the macro, and choose Run. The Developer tab also provides macro controls. If you assigned a shortcut, you can use it while the workbook is open, provided it does not conflict with another shortcut.

Absolute and relative references

One important recorder setting is Use Relative References, available from View > Macros > Use Relative References. When relative recording is off, Excel commonly records specific cell addresses. A macro that formats B2:D20 may return to that same range on every run, even if the next report starts elsewhere.

With relative references on, recorded movements are more likely to be expressed in relation to the active cell when recording began. For instance, moving one cell down can be replayed as a one-cell move from a new starting position. This is useful for repeating an operation across similar records, but it is not a guarantee that every recorded command will behave as intended from every location.

Choose the mode before recording, and make the starting cell part of your plan. Test the macro from a different starting point if that is how it will be used. A common misunderstanding is that relative references automatically make a macro adapt to any table size; they do not. A macro still needs to account for the data boundaries and the structure of the sheet.

A practical example: preparing a weekly report

Suppose a weekly export always arrives with the same columns and needs a title row, readable headings, date formatting, adjusted widths, and a highlighted total row. These predictable presentation steps are good candidates for recording. Start from the same worksheet layout, record the formatting, stop the recorder, and save the workbook as .xlsm.

Try the macro on a duplicate of the next export. Check that it formats the intended cells, preserves values, and does not leave the selection in an awkward place. If the incoming file sometimes has more rows, a macro that only formats the original fixed range may omit new records. If columns move, a macro that targets fixed column letters may format the wrong information.

For changing data sizes, you may need to edit the recorded VBA or use a more suitable automation method. A recorder can provide a useful starting point: it shows the VBA operations associated with familiar Excel actions. It does not automatically build robust rules for finding the last row, recognizing a changed header, or handling missing data.

Where the recorder falls short

Recorded code can be longer and more fragile than hand-written VBA. It often repeats selections and activates cells or worksheets even when a more direct instruction would work. Those steps can make a macro slower, harder to understand, and more sensitive to changes in the active window.

It also captures the route you took, not necessarily the rule behind it. If you manually select a fixed range, the macro may keep using that range. If you sort by clicking a particular column, it may rely on that column’s position. The recorder generally will not ask what should happen when a required value is blank or when a new column appears.

Use a recorded macro when the workbook structure and procedure are consistent. Consider editing the VBA or choosing another tool when the process needs conditions, error handling, variable-sized data, interaction with other services, or clear reporting when something goes wrong. For a small task, one straightforward macro is often easier to maintain than a complicated recording.

Safety and saving your work

VBA macros can change or delete workbook content, and VBA is capable of actions beyond formatting cells. Treat macro-enabled files from unknown sources with caution. Do not enable macros simply because a document asks you to. Use files from sources you trust, and follow your organization’s security rules.

Save a copy of the workbook before running an unfamiliar macro. Excel’s Undo history does not reverse the actions of a VBA macro, so Ctrl+Z on Windows will not reliably restore the workbook after a macro runs. On Mac, Command+Z is the usual undo shortcut, but it likewise does not undo a macro’s operations. Keep a backup or test copy for work that matters.

Store the macro in This Workbook when it is intended only for that file. Storing it in the Personal Macro Workbook makes it available in Excel for your account across workbooks, but it also means the code is not embedded in each workbook you share. Choose the storage location deliberately, and explain any required steps to colleagues who will use the file.

Common problems and how to fix them

  • The macro is missing after saving: Check whether the file was saved as .xlsm rather than .xlsx. Saving a macro-enabled file in a format that cannot store VBA can remove its macro content.
  • The macro changes the wrong cells: Confirm the active sheet, starting cell, and reference mode used during recording. Re-record with a deliberate starting point or revise the code after testing.
  • The macro does not appear to run: Check that the workbook is open and that Excel has not blocked the macro under its security settings. Follow your organization’s policy; do not lower security settings just to run an untrusted file.
  • It works only on the original report: Look for fixed ranges, column positions, or assumptions about sheet names. A changed layout can invalidate those assumptions even though the macro itself still runs.
  • The macro stops with an error: The workbook may be in a different state than the recording expected, such as a missing worksheet or protected range. Test on a copy and inspect the VBA to identify the step that fails.

Excel desktop, Mac, web, and alternatives

Excel for Microsoft 365 on Mac also supports VBA macros, but ribbon details and some features differ from Windows. VBA that relies on Windows-specific components, including certain controls or system interactions, may not work on Mac. If a workbook will be shared across platforms, keep its VBA as platform-neutral as possible and test it on the versions people will use.

Excel for the web does not create, run, or edit VBA macros. It can open a workbook that contains VBA, but VBA automation requires a supported Excel desktop app. For browser-based Excel workflows, Office Scripts may be an option in eligible Microsoft 365 accounts, and Power Automate can connect supported cloud services. Availability and capabilities depend on the account and organization.

For a task that only needs a repeatable calculation or transformation, a worksheet formula, table feature, or Power Query may be easier to maintain than a macro. Power Query is particularly useful for importing and reshaping recurring data; VBA is more flexible for automating desktop workbook interactions. Choose based on the job, not simply on which tool can record clicks.

Frequently Asked Questions

Is Excel’s macro recorder free?
It is a feature of the Excel desktop application, so access depends on your Excel license or plan. It is not a separate recorder app, and Excel for the web does not run VBA macros.

Can I record a macro without knowing VBA?
Yes. You can record and run many basic macros without writing code. Learning to inspect or edit the generated VBA becomes useful when you need to fix fragile references or handle exceptions.

Can a macro recorder automate work outside Excel?
Excel’s recorder is for actions it can translate into Excel VBA. It is not a general recorder for arbitrary desktop applications or a reliable way to automate every browser or operating-system action.

Why does my recorded macro repeat the wrong cells?
It may have captured fixed cell addresses, or it may be starting from a different active cell or sheet than expected. Check whether Use Relative References was enabled while recording and test the macro from the intended starting point.

Can I use a recorded macro in Excel for the web?
No. Excel for the web does not run VBA macros. Open the workbook in Excel desktop to use its VBA, or investigate Office Scripts for supported web-based automation.

Can I undo a macro with Ctrl+Z?
No. Excel does not provide normal Undo for a macro’s actions. Save a backup or use a copy of the workbook before running a macro that could change important data.

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.