A macro is a saved list of actions that a spreadsheet can replay on demand. You switch on the recorder, perform the task once, and stop. The spreadsheet stores each step as code, and running the macro repeats those steps in seconds. The catch is that the recorder saves exactly what you did, including wrong clicks, fixed cell addresses and anything that only worked because of the layout on the day you recorded it.
What a macro is and what the recorder saves
How a recording becomes code
When you record, the application translates each action into a line of instructions. Formatting a header row, for example, becomes a command that sets the font to bold on a named range. Excel stores this as Visual Basic for Applications (VBA). Google Sheets stores it as Apps Script, which is based on JavaScript.
You never have to read the code to record a macro. You will need to read it once you want to change anything, so it is worth opening the code after your first recording to see what the recorder produced.
Where a macro lives
Where you store a macro determines which files can use it.
- Excel, this workbook: the macro is stored inside one file and runs only there. This is the right default for a first macro.
- Excel, Personal Macro Workbook: a hidden file that opens in the background whenever you start Excel, making the macro available in every workbook. Useful for formatting routines you use everywhere, but it is also a hidden dependency that colleagues will not have.
- Google Sheets, script project: the macro is attached to the spreadsheet file and runs under the account of the person who authorised it.
What a macro cannot do on its own
A recorded macro repeats steps. It does not decide anything. If the data changes shape, the macro does not notice. It will format rows 2 to 500 whether or not those rows contain data, and it will not warn you that the export now has 620 rows.

Skip the setup
Clients, invoices, expenses and tasks in one workbook. A good fit if you run the business from a single file.
Preparation before you press record
SOP 2.1: Prepare a test copy
Make a copy of the file before you record. The recorder captures every action in the active workbook, including accidental edits. Running a half-finished macro on your only copy of last quarter’s figures is the most common way beginners lose work.
SOP 2.2: Rehearse the task manually
Perform the task once without recording, and write down the steps in order. Note which cells you touch, which menus you open and whether any step depends on the data. A rehearsal often reveals that a step you thought was fixed (such as “click the Total row”) actually moves depending on the export.
SOP 2.3: Set the starting position
Put the cursor where the recording should start, usually cell A1. Many recorded macros assume they begin from the selection that was active when recording started. If you record from cell F20 by accident, the macro will carry that assumption into every later run.
SOP 2.4: Choose a clear name
Use a name that describes the outcome, such as FormatSalesExport or ClearMonthlyInputs. Names cannot contain spaces in Excel, and a clear name matters later when you have ten macros and cannot remember which one does what.
Record your first macro in Excel
Excel for the web does not record new macros, so use the desktop version for this module. The steps below are for Windows. On a Mac, the menu names are similar, but the ribbon may look slightly different.
SOP 3.1: Show the Developer tab
The Developer tab is hidden by default.
- Select File, then Options.
- Select Customize Ribbon.
- In the list on the right, tick Developer.
- Select OK.
SOP 3.2: Start the recorder
- Open the test copy of the workbook.
- Select Developer, then Record Macro.
- In the Macro name box, type your chosen name.
- In Store macro in, choose This Workbook for a first attempt.
- Optionally, enter a shortcut key. Use a lowercase letter, because an uppercase letter adds Shift to the shortcut and may clash with an existing Excel command.
- Add a description if the workbook will be shared.
- Select OK.
Excel is now recording. The status bar at the bottom left shows a small square icon, which is the stop button.
SOP 3.3: Decide on relative or absolute references
Before performing any steps, check the Use Relative References button on the Developer tab.
- Absolute references (the default) record fixed addresses. If you select cell B2 and type a value, the macro always writes to B2.
- Relative references record movement from the starting cell. If you select the cell to the right of the active cell, the macro moves one column right from wherever it starts.
Use absolute references when the macro should always hit the same cells, such as a fixed report header. Use relative references when the macro should work on whichever cells are selected when it runs. The worked example below shows the difference.
SOP 3.4: Perform the task slowly
Carry out each step in the order you rehearsed. Avoid scrolling, clicking around, or making exploratory changes, because the recorder captures those too. Select the range, apply the format, and move on.
SOP 3.5: Stop the recorder
Select the stop icon in the status bar, or select Developer, then Stop Recording.
SOP 3.6: Run and verify
- Clear the formatting you applied, or open a fresh copy of the file.
- Press Alt + F8 to open the macro list.
- Select your macro and choose Run.
- Check the result cell by cell.
SOP 3.7: Save in the correct format
Save the workbook as an Excel Macro-Enabled Workbook (.xlsm). If you save it as .xlsx, Excel removes the macro without warning. This is the single most common reason a working macro appears to vanish.
Record your first macro in Google Sheets
Google Sheets has no separate Developer tab. The recorder sits under the Extensions menu.
SOP 4.1: Start the recorder
- Open the test copy of the spreadsheet.
- Select Extensions, then Macros, then Record macro.
- Choose the cell where recording should start, and select Start recording.
SOP 4.2: Perform the task
Carry out the steps as you rehearsed them. Sheets records formatting changes, typed values and most menu actions. Some actions do not record, and the recorder does not capture scrolling or viewing, so the code will not reproduce every interaction you made.
SOP 4.3: Save the macro
- Select Save in the recorder dialogue.
- Give the macro a name.
- Optionally assign a keyboard shortcut.
SOP 4.4: Find and edit the code
Select Extensions, then Apps Script to open the script editor. The recorded function appears there. Reading it is the fastest way to understand what the recorder did, and it is where you will make any changes.
SOP 4.5: Authorise on first run
The first time you run the macro, Google asks you to authorise the script to access the spreadsheet. Read the permissions screen. A script attached to a shared file runs under the authorising account, so only authorise scripts you have reviewed.

Ready-made template
Sales, costs, cash and targets on one screen. The formulas are already built, so you type the numbers and the dashboard does the rest.
Worked example, formatting a monthly sales export
This example uses a common task. A system exports monthly sales to a spreadsheet with six columns: Date, Region, Product, Units, Price and Revenue. The export has a plain header row, no currency formatting and no filter. Each month you format it the same way.
Step 1: Define the outcome
The finished sheet should have:
- a bold header row with a light blue background
- column C (Price) and column F (Revenue) formatted as pounds with two decimal places
- columns sized to fit their contents
- a filter on the header row
Step 2: Record the steps
In Excel, the recorded code looks roughly like this once tidied up:
Sub FormatSalesExport()
Range("A1:F1").Font.Bold = True
Range("A1:F1").Interior.Color = RGB(221, 235, 247)
Range("C2:C500").NumberFormat = "£#,##0.00"
Range("F2:F500").NumberFormat = "£#,##0.00"
Columns("A:F").AutoFit
Range("A1:F1").AutoFilter
End Sub
The recorder will also add Select lines and some extra commands. Those do no harm, but they slow the macro and make the code harder to read. Once you understand the basic pattern, you can delete them.
Step 3: Spot the hidden assumption
The formatting range runs from row 2 to row 500. That number came from the export on the day you recorded it. If next month’s export has 620 rows, the last 120 rows will keep the default format, and nothing will warn you. If it has 180 rows, the macro will format 320 empty rows, which adds unnecessary formatting to the file.
The fix is to find the last row in code rather than hard-coding 500. In Excel, a typical approach is:
Dim lastRow As Long
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("C2:C" & lastRow).NumberFormat = "£#,##0.00"
You would not write this on your first attempt. It is a good example of the edit that turns a recording into a reusable tool.
Step 4: Compare absolute and relative results
Suppose you want the macro to bold whichever header row is active, even if the export starts at row 5 one month. With absolute references, the macro bolds row 1, which is wrong. With relative references, the macro bolds the row where recording began, which works only if every export starts in the same place. Neither is fully general. This is why the next step, editing the code to find the last row or header row, matters more than the recording itself.
Step 5: Test on a second file
Run the macro on a second export with a different number of rows. Check the first row, the last row, the number formats at the boundary, and whether the filter covers the right range. A macro that works on one file has been tested once.
Choosing between recording and writing code
Recording suits repetitive formatting and simple, predictable steps. Writing code by hand suits anything that must make decisions, handle variable data or run without supervision.
| Attribute | Recorder | Hand-written code |
|---|---|---|
| Time to first working result | Minutes | Hours to days, depending on experience |
| Handles variable row counts | Only if edited afterwards | Yes, by design |
| Makes decisions (if this, then that) | No | Yes |
| Readability for others | Often cluttered | Can be clean if well structured |
| Breaks when layout changes | Often | Less often, if references are named |
| Learning curve | Low | Moderate to high |
| Best use | Fixed formatting, repeated clicks | Imports, validation, multi-sheet logic |
For most beginners, the sensible path is to record first, read the code second, and edit the three or four lines that cause trouble. Writing from scratch can come later.
When a formula is the better tool
Some tasks that look like macro work are better handled by a formula. If you want a column to show “Over target” when revenue exceeds a threshold, an IF formula in a helper column updates itself and needs no macro. Macros should change the structure or formatting of a file. Formulas should calculate values. Mixing the two is fine, but the macro should not do work a formula could do more transparently. For the functions most worth learning before you automate anything, the guide to essential spreadsheet formulas and functions covers the basics.
Decision rule and checklist
Record a macro when a task is repetitive, predictable and takes more than a couple of minutes by hand. Do not record a macro for a task you do once, or for a task whose steps change each time. Stop and edit the code when the macro depends on a fixed row count, a fixed sheet name or a layout you cannot guarantee.
Before you consider a macro finished, check the following:
- The recording was made on a test copy.
- Relative or absolute references were chosen on purpose.
- The file is saved as
.xlsmin Excel, or the script is saved in Apps Script. - The code has no hard-coded row limit, or the limit is documented.
- The macro has been run on at least two files with different data sizes.
- Any protected sheets, merged cells or hidden rows have been checked.
- A short note explains what the macro expects and what it changes.
- Anyone else who uses the file knows the macro exists and how to run it.

Get the finished file
Paidmark Invoice and Estimate Kit
Invoices, estimates, receipts and a payment tracker that flags what’s overdue, all in one Excel file.