To record a macro in Excel, open the Developer tab, select Record Macro, give the macro a name, select OK, carry out the actions you want Excel to repeat, and then select Stop Recording. Excel saves your actions as Visual Basic for Applications (VBA) code that you can replay whenever you need it.
Applies to: Excel for Microsoft 365, Excel 2024, Excel 2021, Excel 2019 and Excel 2016 on Windows, plus Excel for Microsoft 365 for Mac, Excel 2024 for Mac and Excel 2021 for Mac. Checked against Microsoft Support on October 7, 2026.
What a recorded macro is
A macro is an action, or a set of actions, that you can run as many times as you want. When you record one, Excel’s Macro Recorder writes down each step as VBA code, so you do not have to write any code yourself. A typical use is a formatting routine you repeat every month, such as making overdue customer names red and bold in a report.
Microsoft notes that the recorder captures almost every move you make. That includes mistakes: if you click the wrong button during a recording, the wrong click becomes part of the macro. A smooth, planned recording gives you a macro that runs more efficiently.
Before you start
- Use the desktop app. You cannot create, run or edit VBA macros in Excel for the web. If the workbook is open in a browser, select Open in Desktop App above the ribbon first.
- Show the Developer tab. It is hidden by default. The steps are in the next section.
- Work on a copy. Macros cannot be undone. Save the workbook before you run a new macro for the first time, or better, test it on a copy so an unexpected result does not damage real data.
- Rehearse the steps. Run through the task once without recording so you know the exact order of clicks and keystrokes.
Show the Developer tab in Excel for Windows
- Select File, then Options. The Excel Options window opens.
- Select Customize Ribbon.
- Turn on the check box for Developer in the list of tabs, then confirm the change. The Developer tab now appears on the ribbon.
Record a macro in Excel for Windows
- Open the workbook you want to automate and select the cell or sheet where the task begins.
- On the Developer tab, in the Code group, select Record Macro. You can also press Alt+T+M+R. The Record Macro dialog box opens.
- In the Macro name box, type a descriptive name such as Format_Overdue. The first character must be a letter. The rest can be letters, numbers or underscore characters. Spaces are not allowed.
- Optional: in the Shortcut key box, type a letter. A lowercase letter creates a Ctrl+letter shortcut, and an uppercase letter creates a Ctrl+Shift+letter shortcut. Read the warning about shortcuts below before you choose one.
- In the Store macro in list, choose where the macro lives. This Workbook is the usual choice. Pick Personal Macro Workbook if you want the macro available whenever you use Excel.
- Optional: type a short note about what the macro does in the Description box. It helps when you have several macros and cannot remember which is which.
- Select OK. Recording starts immediately, so everything you do from this point is captured.
- Perform the actions you want to automate, for example typing text, applying formatting or filling in a formula.
- On the Developer tab, select Stop Recording, or press Alt+T+M+R again. The macro is now stored in the location you chose.

Choosing a shortcut key safely
A macro shortcut overrides any matching built-in Excel shortcut for as long as the workbook that contains the macro is open. If you assign Ctrl+C to a macro, for example, Ctrl+C runs your macro instead of copying while that workbook is open. Using an uppercase letter, which gives you a Ctrl+Shift combination, makes a clash less likely. You can add or change the shortcut later: select Developer, then Macros, select the macro, select Options and type a letter in the Shortcut key box.
This Workbook or Personal Macro Workbook?
A macro stored in This Workbook travels with that file and is the right choice for a task tied to one spreadsheet. A macro stored in the Personal Macro Workbook goes into a hidden workbook named Personal.xlsb, which Excel creates if it does not already exist. Excel keeps that file in its XLSTART folder, so your personal macros are available in every workbook on that computer. When you close Excel after recording to the personal workbook, you are asked to save it as well. Say yes, or the new macro is lost.
Record a macro in Excel for Mac
- Select Excel, then Preferences, then Ribbon & Toolbar.
- Under Main Tabs, turn on Developer, save the change and close Preferences.
- Decide how cells should be recorded. If the macro should work from whichever cell is selected when you run it, select Use Relative References on the Developer tab before you record. Leave it off to record exact cell addresses.
- On the Developer tab, select Record Macro.
- Type a name in the Macro name box. Start with a letter and use underscores instead of spaces.
- In the Store macro in list, choose This Workbook.
- Optional: type a letter in the Shortcut key box and add a Description. On a Mac, a lowercase letter gives you an Option+Command+letter shortcut. As on Windows, the shortcut overrides the matching Excel default while the workbook is open.
- Start the recording, then perform the actions you want to automate.
- On the Developer tab, select Stop Recording.
Relative or absolute references: decide before you record
By default, a recording stores specific cell addresses. If you format cells A1 to A10 during the recording, the macro formats A1 to A10 every time, no matter which cell is selected when you run it. Microsoft’s own example of this limit is a range that grows: if you record a task on a range and later add an extra row, the macro still runs only on the cells in the original range.
Relative recording stores movements instead, such as “one cell to the right of where I started,” so the same macro can be replayed in different parts of a sheet. Microsoft’s Excel for Mac instructions name the control Use Relative References on the Developer tab. Microsoft’s Windows recording steps do not mention it, so on Windows check the Developer tab for that control before you select Record Macro. Whichever mode you use, test the result on a copy from a few different starting cells.
Run the macro to confirm it worked
- Open a copy of the workbook, or undo your recorded changes by hand so you have something to test on.
- On the Developer tab, select Macros, or press Alt+F8. A list of available macros opens.
- In the Macro name box, select your macro and select Run. Excel replays the recorded actions. If you assigned a shortcut key, pressing it does the same thing.
If the result matches what you did by hand, the recording is good. Our guide on how to run macros in Excel covers the other ways to start one.
Save the workbook so the macro is kept
The standard Excel Workbook format (.xlsx) cannot store VBA macro code. If your macro is stored in This Workbook, select File, then Save As, and choose the Excel Macro-Enabled Workbook format, which uses the .xlsm extension. If you save as a regular .xlsx file instead, the recorded macro is not kept. Macros stored in the Personal Macro Workbook are saved in Personal.xlsb, so the workbook you were working in can stay in .xlsx format.
Fix, edit or delete a recording
For a short macro, the simplest way to fix a mistake is to record it again. To look at what Excel wrote, select Developer, then Macros, select the macro and select Edit. This opens the Visual Basic Editor, which you can also reach with Alt+F11. Step Into in the same dialog box opens the editor at the first line of the macro so you can run it one line at a time. Reading the code of a macro you recorded yourself is a gentle way to start learning VBA.
To remove a macro you no longer want, open the same macro list from the Developer tab, select the macro and delete it there.
Microsoft also suggests keeping macros small. If you have a long process to automate, record several short macros that each do one job instead of one very long recording. Short macros are easier to test and to record again when something changes.
Troubleshooting
The Developer tab or Record Macro is missing
The tab is hidden until you turn it on in File > Options > Customize Ribbon on Windows or Excel > Preferences > Ribbon & Toolbar on a Mac. If you are working in a browser, there is no macro recorder at all: Excel for the web can open a workbook that contains macros and let you edit the data, but creating and running them requires the desktop app.
The macro will not run when you reopen the file
Excel disables macros in many files until you allow them. When a warning bar appears, select Enable Content only if you know where the macro came from and what it does. The setting behind this is in File > Options > Trust Center > Trust Center Settings > Macro Settings. The option Disable all macros with notification turns macros off but shows an alert so you can decide file by file. Do not switch to Enable all macros (not recommended, potentially dangerous code can run) just to make one workbook work. See our guide on how to enable macros in Excel for a walkthrough of these settings.
“Microsoft blocked macros from running because the source of the file is untrusted”
On Windows, Office blocks macros in files that came from the internet or an email attachment. If the file is your own or from someone you trust, close it, right-click the file, select Properties, turn on the Unblock check box on the General tab and select OK.
The settings are greyed out on a work or school computer
If your device is managed by your work or school, the administrator can prevent anyone from changing macro settings, and can block internet macros by policy. In that case, ask your IT team instead of looking for a workaround.
The macro changes the wrong cells
This is almost always the relative versus absolute issue described above. Record the macro again in the other mode, starting from the cell you will normally start from.
The macro disappeared after saving
The workbook was saved as .xlsx, which cannot hold VBA code. Record the macro again and save the file as an Excel Macro-Enabled Workbook (.xlsm).
A normal keyboard shortcut stopped working
Your macro’s shortcut key has taken over that key combination while the workbook is open. Change the letter under Developer > Macros > Options.
Frequently asked questions
Do I need to know VBA to record a macro?
No. The Macro Recorder writes the VBA code for you while you work. You only need the Visual Basic Editor if you want to read or change what was recorded.
Can I undo a macro after running it?
No. Microsoft states that macros cannot be undone, which is why it recommends saving first or testing on a copy of the workbook.
Can I record a macro in Excel for the web?
Not a VBA macro. Excel for the web cannot create, run or edit them. Microsoft offers a separate feature called Office Scripts, with an Action Recorder on the Automate tab, for people whose Microsoft 365 subscription includes it and whose administrator has not turned it off. Office Scripts are not the same thing as VBA macros.
How do I use my macro in every workbook?
Choose Personal Macro Workbook in the Store macro in list when you record. Excel stores the macro in the hidden Personal.xlsb file so it is available whenever you use Excel. To use the same macros on another computer, Microsoft says you can copy Personal.xlsb into the XLSTART folder on that computer.
Can a recorded macro work in other Office apps?
Microsoft says a macro process is not limited to Excel and can extend to other Office applications and other applications that support VBA. That normally means editing the code by hand, which goes beyond a simple recording.
Is it safe to open workbooks with macros from other people?
Only when you trust the source. A macro can run harmful code, so Microsoft’s guidance is never to enable macros unless you know what they do and want that functionality.
Once your first recording works, record a second short macro for another routine task and compare the two in the Visual Basic Editor. Microsoft’s full reference is Automate tasks with the Macro Recorder.
Related: how to create a macro in Windows 10.
Related: create folders from an Excel list.
Related: enable macros in Excel on a Mac.

Matt Jacobs has been working as an IT consultant for small businesses since receiving his Master’s degree in 2003. While he still does some consulting work, his primary focus now is on creating technology support content for SupportYourTech.com.
His work can be found on many websites and focuses on topics such as Microsoft Office, Apple devices, Android devices, Photoshop, and more.