Yes. Microsoft Excel for Microsoft 365 includes a built-in macro recorder: choose Developer > Record Macro, perform the steps you want to repeat, and select Developer > Stop Recording. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) so the recorded macro can be kept and run later.
What Excel’s macro recorder does
A macro is a saved sequence of instructions for Excel. The recorder observes many actions you take—such as entering text, applying number formats, adjusting column widths, or sorting a selected range—and translates them into Visual Basic for Applications (VBA) code. You can run that code again instead of repeating the same steps manually.
This makes recording a practical first step for simple, repetitive work, even if you have never written code. For example, a person who receives a weekly report might record steps to bold the header row, format a sales column as currency, and autofit the columns. The result can save time when the same layout and operations recur.
The recorder is not an intelligent assistant that understands the purpose of a task. It captures actions and references. It does not automatically infer that next week’s report has more rows, decide which records are unusual, or build a flexible process for changing data. Understanding that distinction helps set realistic expectations.
Show the Developer tab and start recording
The Developer tab is where Excel puts its macro tools. If it is not visible in Excel for Microsoft 365 on Windows, enable it through File > Options > Customize Ribbon, select the Developer check box in the main tabs list, and choose OK. On Mac, open Excel > Settings > Ribbon & Toolbar, select Developer, and save the change. The precise wording can vary slightly by release.
To record a macro on Windows, follow these steps:
- Open the workbook and select the worksheet where the task should begin.
- Choose Developer > Record Macro.
- In the dialog, enter a name without spaces, such as FormatWeeklyReport. Macro names can include underscores. Choose a storage location and, if useful, add a description.
- Optionally assign a shortcut key. Avoid replacing a shortcut you rely on; Excel warns about conflicts in the dialog.
- Choose OK, then perform the task in the same order you want Excel to repeat it.
- When finished, choose Developer > Stop Recording.
Excel for Mac also provides Record Macro and Stop Recording from the Developer tab. A macro created on one platform may need checking on the other if it uses platform-specific features, file paths, or controls. Basic worksheet formatting and cell-editing macros are generally more portable than code that interacts with the operating system.
Choose the right recording options
The Record Macro dialog contains choices that affect where the macro is stored and how you can use it. The storage location matters particularly when you expect to share or reopen the macro.
- This Workbook: stores the macro in the current workbook. This is usually the clearest choice when the macro belongs to one report or template. The file must be saved in a macro-enabled format to retain VBA.
- Personal Macro Workbook: stores a macro in a hidden workbook that Excel opens for your user account. It can make a personal utility available in other workbooks on that computer, but it is not automatically included when you send someone a separate workbook.
- New Workbook: puts the recorded macro in a new workbook, which may be useful when creating a separate macro file.
A description is useful if you later collect several macros with similar names. A shortcut can make a frequently used macro quicker to launch, but it is optional; you can also select a macro from Excel’s macro list. Keep the shortcut uncomplicated and memorable, and make sure you understand whether it overrides an existing Excel shortcut.
A concrete example: format a recurring report
Suppose each weekly report arrives with column headings in row 1, dates in column A, and sales amounts in column C. You want the headings bold, the sales values displayed as currency, and the columns wide enough to show their contents. Start recording with the cursor in the report, then select the heading cells and apply bold. Select the sales data and choose an appropriate currency format from Home > Number. Select the columns you need and use Home > Format > AutoFit Column Width. Stop the recording when the layout is ready.
Run the macro on a copy of a later report first. If the new report has the same layout and the same relevant cells, the recorded sequence may work as expected. If the number of rows changes, however, the macro might format only the exact cells selected during recording. A recorder does not necessarily turn a selection such as C2:C25 into a rule meaning all sales values in column C.
That is a useful distinction between automating a repeated action and automating a whole process. A recorded macro can reliably replay a fixed set of operations. A process that must find the last populated row, handle missing columns, or adapt to different report formats often needs edited VBA or a different tool.
Absolute and relative references
One important recorder control is Relative References, found on the Developer tab in the Code group. When relative recording is off, Excel commonly records actions in relation to specific worksheet cells. If you selected B2 and applied formatting, running the macro later may apply that formatting to B2 again, even if your active cell is elsewhere.
When Relative References is on, Excel records many cell movements in relation to the starting position. For instance, a macro that moves one cell right and applies a format can repeat that move from another starting cell. This can make a macro more reusable across rows or columns, but it does not make every recorded operation dynamic. Some actions still refer to particular ranges or depend on the worksheet layout.
Before recording, decide whether the action should always affect the same cells or should follow the current selection. Turn Relative References on or off before you begin, and check its state in the Developer tab. If the macro behaves unexpectedly, record a short test with a small sample and inspect the result before relying on it for a full report.
Where recording works—and where it falls short
The recorder is strongest when the task is a stable sequence of commands in Excel’s interface. Formatting cells, entering repeated labels, applying a known sort, and copying a fixed layout are reasonable candidates. It can also help a beginner learn VBA: the recorded code gives a starting point that can be examined and modified.
It has limits. A recorded macro usually reflects the exact selections and commands made during recording, rather than the goal behind them. It does not automatically create decision-making logic such as “if the value is blank, skip this row,” or a loop that processes every worksheet in a workbook. It may also capture unnecessary selections and navigation, making the code longer and more fragile than a carefully written macro.
For a task that changes regularly, inspect the macro rather than assuming it will adapt. In Windows, choose Developer > Macros, select the macro, and choose Edit to view its VBA code. The Visual Basic Editor is also available from Developer > Visual Basic. On Mac, the Developer tab provides access to macros and the Visual Basic Editor as well. You do not have to edit the code to use a simple recording, but reviewing it can reveal fixed cell addresses or other assumptions.
Run, save, and share a recorded macro
To run a macro, choose Developer > Macros, select its name, and choose Run. You can also use a shortcut assigned during recording. Test the macro on a duplicate or a disposable copy of important data before using it on the original. A macro can change many cells quickly, and Excel’s Undo command, including Ctrl+Z on Windows, does not undo VBA macro actions.
To preserve a macro in the current workbook, use File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm). A standard .xlsx workbook cannot store VBA macros; saving a macro-containing workbook as .xlsx removes the macro content. When sharing the file, tell recipients what the macro does and where it came from. They may need to allow the macro under their organization’s security rules before it can run.
If a macro is stored in the Personal Macro Workbook, it is attached to the Excel installation and user profile rather than bundled into an ordinary report file. For portability, store a macro in the workbook that needs it, or distribute a suitable macro-enabled workbook. Organizational policies may restrict macro-enabled files or macros from certain sources.
Safety and common problems
Macros can make changes to a workbook and, depending on their code, can interact with files or other resources. Only enable macros when you trust the file and understand its source. Do not lower Excel’s security settings simply because a file displays a warning. In Windows, macro controls are under File > Options > Trust Center > Trust Center Settings > Macro Settings; organizations may manage these settings centrally. On Mac, macro security options are under Excel > Settings > Security.
- The macro is missing after saving: check that the workbook was saved as .xlsm, not .xlsx, and confirm that the macro was stored in This Workbook rather than the Personal Macro Workbook.
- The macro is unavailable or blocked: confirm that macros are permitted by your Excel settings and workplace policy. Do not enable an untrusted file just to bypass a warning.
- It affects the wrong cells: check the starting selection, the Relative References setting, and whether the recorded range is fixed.
- It works only on one report: the macro may depend on a sheet name, cell address, or layout that changed. Record a test on a representative copy, then consider editing the VBA or using a more adaptable approach.
When to use another approach
If the task is a repeatable sequence of clicks and cell changes, the recorder is often the easiest entry point. If you need to combine steps, add conditions, loop through sheets, or respond to varying data sizes, VBA may be more suitable, though it requires code review and testing. For importing and reshaping recurring data, Excel’s Power Query tools may be a better fit than replaying worksheet actions. For a simple repeatable calculation, a normal worksheet formula may be clearer and safer than a macro.
Choose the tool based on what changes between runs. If only the data values change while the layout stays fixed, a short recorded macro may be enough. If the layout, number of records, or rules change, prioritize an approach that explicitly handles those variations. The recorder can still provide a useful starting point, but it should not be mistaken for a complete substitute for logic and testing.
Frequently Asked Questions
Is Excel’s macro recorder easy for beginners?
Yes, for simple tasks. You can record formatting or cell operations without writing VBA, but you should test the result and understand that recorded actions may depend on fixed cell selections.
Do I need to know VBA to record a macro?
No. Excel creates the VBA code while you record. VBA knowledge becomes helpful when you need to adjust the code, add conditions, or make a macro handle changing ranges.
Why can’t I save my macro in an .xlsx file?
The .xlsx format does not preserve VBA macro code. Save the workbook as Excel Macro-Enabled Workbook (*.xlsm) to keep a macro stored in that file.
Can I run the same recorded macro on another workbook?
Sometimes. It depends on where the macro is stored and whether the other workbook has the same worksheet names, cell layout, and ranges. Test on a copy before using it on important data.
Can I undo a macro after it runs?
Usually not with Excel’s Undo command. Save a backup or work on a copy before running a macro that changes data, because VBA actions generally cannot be reversed with Ctrl+Z.
Related
- How to Change a Date Format to a Custom Format in Excel
- How to Change Short Date Format in Excel for Dates
- Change Date Format to Text in Excel: 3 Reliable Ways
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Create a Pivot Table in Excel Using VBATo create a PivotTable with VBA, prepare a rectangular data range with clear headers, then use a PivotCache…
- VBA to Compare Two Word Documents AutomaticallyTo compare two Word files with VBA, open both documents and call Word’s Application.CompareDocuments method. It creates a…
- Excel Macro to Pull Data From Other Worksheets SafelyYes. In Excel for Microsoft 365 on Windows, a VBA macro can read ranges from other worksheets and…
- VBA Loop Through a Range: Examples and Best PracticesTo loop through cells in Excel VBA, use For Each cell In worksheet.Range("A1:A10").Cells and place the action you…
- VBA Loop Through Files in a Folder: Examples and TipsTo loop through files in a folder in Excel VBA, use the Dir function: give it a folder…
- Excel VBA UserForm Examples: Forms, Code, and Setup GuideCommon Excel VBA UserForm examples include a contact-entry form, a search box, a data-editing dialog, and a task-specific…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.