What a macro does and when you need one

A macro is a set of steps you record once and then run with a single click or keyboard shortcut. If you do the same sequence of actions repeatedly — formatting a column, copying data from one sheet to another, deleting blank rows — a macro saves you from repeating those steps by hand every time.

You do not need to write code. Excel's macro recorder watches what you do, remembers it, and plays it back. The recorder captures clicks, typing, and menu choices. When you run the macro later, Excel performs those exact steps in the same order.

Macros are most useful when you perform the same task on different files or different parts of the same file. A one-time task does not need a macro. A task you do five times a week does.

Key Takeaways

  • Open the Developer tab in Excel, click Record Macro, give it a name, then perform the steps you want to repeat while Excel watches.
  • Stop the recorder when you finish, and Excel saves your macro as a reusable sequence you can run from the Macros dialog or a keyboard shortcut.
  • Macros work best for repetitive formatting, copying, and moving data — not for decisions that change based on what is in your spreadsheet.
  • Saving a file with macros requires choosing the .xlsm format instead of the standard .xlsx, and you must enable macros when you open the file.

Enable the Developer tab first

The macro recorder lives in the Developer tab, which is hidden by default. You must turn it on before you can record anything.

In Excel, click File, then Options. In the left sidebar, click Customize Ribbon. On the right side, check the box next to Developer, then click OK. The Developer tab now appears at the top of your screen between Data and Design.

Record your first macro

Click the Developer tab. In the Code group, click Record Macro. A dialog box opens asking for a name and an optional description.

Name your macro something you will recognize — "FormatSalesData" or "CopyToArchive" works better than "Macro1". You can also assign a keyboard shortcut here (like Ctrl+Shift+F) if you want to run it without opening a menu. Leave the Store Macro Location set to This Workbook unless you want the macro available in every file you open.

Click OK. The recorder is now running. Every click, keystroke, and menu choice you make will be recorded. Perform the exact steps you want to repeat. Work slowly and deliberately — the macro will replay at the same pace, so if you pause or backtrack, the macro will too.

When you finish, click Developer again, then click Stop Recording. Your macro is now saved.

Run your macro

To run a macro you recorded, click Developer, then click Macros. A list of all macros in your workbook appears. Click the one you want, then click Run.

If you assigned a keyboard shortcut when you created the macro, you can run it by pressing that shortcut instead. For example, if you set Ctrl+Shift+F, pressing those keys together will run the macro when ready.

The macro performs every step you recorded, in the same order, at the same speed. If something goes wrong, press Ctrl+Z to undo.

Save your file in the right format

Files with macros must be saved as .xlsm (Excel Macro-Enabled Workbook), not the standard .xlsx format. When you save a file that contains a macro, Excel asks which format you want. Choose Excel Macro-Enabled Workbook.

If you save as .xlsx by mistake, your macro will be deleted. If you open a .xlsm file, Excel may show a yellow security bar asking whether to enable macros. Click Enable Content to use them. This protection exists because macros can be used maliciously, so Excel requires you to approve them each time you open a file from an untrusted source.

What macros can and cannot do well

Macros work reliably for formatting (bold, color, borders), copying and pasting, moving between sheets, and deleting rows or columns. They also handle typing the same text repeatedly and explore the same filter or sort.

Macros struggle with decisions. If you need to do different things based on what is in a cell — "if this number is over 100, format it red; otherwise leave it alone" — a macro cannot make that choice. That requires writing actual code, which is beyond the recorder. For straightforward conditional formatting, use Excel's built-in conditional formatting feature instead of a macro.

Macros also assume the data is in the same place every time. If your data starts in column A one week and column B the next, the macro will look in the wrong place. Macros work best on files with a consistent structure.

Edit or delete a macro

If you recorded a macro and realized you made a mistake, you can delete it and record again. Click Developer, then Macros. Click the macro name, then click Delete. It is gone when ready.

You can also edit a macro by clicking Developer, Macros, selecting the macro, and clicking Edit. This opens a code editor. If you know how to write Excel code (called VBA), you can fix errors or add features. If you do not, it is safer to delete and re-record.

Frequently Asked Questions

Can I run a macro on multiple files at once?

A macro only works on the file it is saved in. To use the same macro on many files, save it in a template or in the Personal Macro Workbook (a hidden file Excel creates). Then the macro is available in every file you open. This requires editing the macro location, which is more advanced than basic recording.

What if my macro runs too fast or too slow?

Macros replay at the speed you recorded them. If you recorded slowly with pauses, the macro will be slow. Re-record it, working at the pace you want. There is no setting to speed up or slow down a recorded macro without editing the code.

Can I undo a macro after it runs?

Yes. Press Ctrl+Z when ready after the macro finishes, and Excel will undo all the steps the macro performed. You can undo multiple times to go back further, just like undoing manual work.

Will my macro work if I open the file on a different computer?

Yes, as long as the file is saved as .xlsm and you enable macros when prompted. The macro will run the same way on any computer running Excel. However, if the other computer has a different version of Excel or a different language setting, some formatting or text may behave differently.

What is the difference between recording a macro and writing code?

Recording captures your actions. Writing code lets you give Excel instructions it cannot record, like "repeat this 50 times" or "only do this if the value is greater than 100". Code is more powerful but requires learning a programming language. Start with recording for straightforward, repetitive tasks.