Yes. Google Sheets has macros: you can record a sequence of spreadsheet actions and replay it later, or customize the generated Google Apps Script code for more control. To record one in a browser, open a Google Sheets file and choose Extensions > Macros > Record macro.
How Google Sheets macros work
A macro is a saved routine for repeating work in a spreadsheet. When you record a macro, Sheets captures supported actions—such as entering or formatting data—and turns them into a function in a Google Apps Script project attached to that spreadsheet. When you run the macro, that script performs the recorded steps again.
This means a Sheets macro is not a separate recording file, nor is it the same technology as an Excel VBA macro. The recording is a convenient way to create script code without writing it from scratch. You can use the recording as-is for a simple, repeatable task, or open the script and modify it if the task needs logic the recorder cannot capture.
Macros are most useful when the same steps need to be applied repeatedly to similar data. For example, a monthly report might need a standard heading, consistent number formats, frozen header rows, and a filter. A macro can take care of those routine steps while leaving you to check the figures and interpret the results.
How to record and run a macro
Use the desktop version of Google Sheets in a web browser. The command is part of Sheets, so you do not need to install a separate macro recorder. The basic process is:
- Open a Google Sheets spreadsheet. If you are working with an Excel file, convert it to Google Sheets format before relying on Sheets macros.
- Choose Extensions > Macros > Record macro.
- Choose whether to use absolute or relative references. The choice affects how cell-based actions replay.
- Carry out the actions you want to record, such as applying a number format, adding a border, or entering a standard label.
- Click Save, give the macro a clear name, and optionally assign a keyboard shortcut when the save dialog offers that option.
To run it later, select Extensions > Macros and choose the saved macro. If you assigned a shortcut, Sheets displays the shortcut with the macro in that menu. On its first run, the script may ask you to authorize access. Read the prompt and proceed only if you understand and trust what the script will do.
Try a new recording on a copy of the spreadsheet first. A macro can act on the wrong cells if the selection or layout differs from what you expected, and script-driven edits are not always recoverable with Undo.
Absolute and relative references
The reference setting is important because it determines whether a macro repeats actions at the same addresses or in relation to where you start. With absolute references, a step recorded for cell B2 targets B2 when the macro runs again. That suits a fixed template where the same cells always need the same treatment.
With relative references, the action is replayed relative to the active cell. Imagine selecting A2 and recording a step that formats the cell two columns to the right. If you later select A20 before running the macro, the corresponding action applies at C20 rather than C2. That can be useful when processing a new row or section each time.
Choose based on the shape of the task, not simply on whether the data changes. A macro that applies a title style to a fixed cell in a report may need absolute references. A macro that formats the next row of imported records may be a better fit for relative references. Test the macro from more than one starting cell if you expect to use it in different places.
What macros can and cannot automate
Recorded macros handle many straightforward operations, especially actions involving cells, formatting, and spreadsheet layout. They can save time on repetitive preparation, but they are not a guarantee that every menu command or workflow can be recorded exactly as performed. If a particular action is not captured, the script may need to be edited, or the process may need another tool.
Recording also does not automatically make a task adaptable. A macro may reproduce a fixed sequence rather than understand what the data means. For instance, recording a sort on a particular range may not account for a later report with extra rows or a moved column. Likewise, a macro that pastes values into a fixed block can overwrite content if the sheet has changed since the recording.
Before depending on one, consider whether the spreadsheet layout is stable and whether the task needs decisions. A simple, repeated formatting routine is a strong candidate. A task that must identify changing ranges, check conditions, handle errors, or update multiple sheets may require editing Apps Script or choosing a different automation method.
Editing a macro with Google Apps Script
Because a macro is represented by Apps Script code, you can inspect or revise that code from the spreadsheet by choosing Extensions > Apps Script. The editor shows the script project associated with the file. A recorded macro appears as a function, and the macro menu is linked to functions that Sheets can run as macros.
This opens the door to more advanced behavior, such as adding conditional steps, working with a range selected by code, or applying a repeatable operation across several tabs. It also means the tool has a learning curve: editing code incorrectly can cause an error or produce unexpected changes. Keep the original recording or make a copy before experimenting, and make small changes that you can verify.
Apps Script is broader than the macro recorder. You can write scripts directly rather than record actions, and Apps Script also supports other ways to extend Google Workspace. But a macro remains a useful starting point for someone who wants to see how a routine translates into code before deciding whether to learn more scripting.
Permissions, safety, and sharing
A macro runs script code, so treat it as automation rather than as a harmless visual shortcut. When a script needs access to a spreadsheet or another Google service, Google may show an authorization screen. The requested permissions depend on the code and the services it uses. Do not approve a request just because a spreadsheet contains a macro; check that you trust the file and understand why access is requested.
For a macro you created yourself, review its code in Extensions > Apps Script if you are unsure what it does. Be particularly cautious with spreadsheets received from someone else, especially if the script requests broader access than the task seems to require. A macro can also change or overwrite spreadsheet content, so save a separate copy before running unfamiliar automation.
Sharing a spreadsheet and sharing confidence in its script are not the same thing. People with access to a file may encounter its attached automation, while authorization and account policies can affect who is able to run it. In an organization, an administrator may restrict Apps Script or related services. If a colleague cannot run a macro, check both their spreadsheet access and the organization’s script policies rather than assuming the recording is broken.
Google Sheets macros compared with Excel macros
Both programs can automate repetitive spreadsheet work, but their macro systems are different. Google Sheets macros use Apps Script, a JavaScript-based scripting environment tied to Google Sheets. Excel macros commonly use VBA, and Microsoft 365 also has other automation options. A macro written in one system does not simply run in the other.
For example, an Excel workbook containing VBA code will not have that VBA macro converted into a working Sheets macro just by opening or importing the workbook. If you move the spreadsheet to Sheets, you may need to recreate the routine with the Sheets recorder or rewrite its logic in Apps Script. The reverse is also true: Apps Script code is not an Excel VBA macro.
Choose based on where the spreadsheet lives and what your team needs. Sheets macros suit workflows that are already in Google Sheets and benefit from its browser-based collaboration. Excel may be a better fit when a process depends on existing VBA, Excel-specific features, or a Windows desktop workflow. For a cross-platform task, compare the actual script capabilities and access requirements rather than assuming the macros are interchangeable.
Common problems and how to fix them
If the Macros menu is missing or the recording option is unavailable, first check that you are using a Google Sheets file in a desktop browser. An Excel-format file opened for editing is not the same as a native Sheets spreadsheet; convert it if you intend to use Sheets-specific features. A workplace administrator’s restrictions can also affect Apps Script.
If a macro runs but changes the wrong cells, check its absolute or relative reference setting and the cell selected before running it. Compare the current sheet with the layout used during recording. Look for inserted rows, moved columns, merged cells, or a different active tab, since these can make a fixed sequence behave differently from what you intended.
If it stops with an authorization prompt or an error, read the message rather than repeatedly running it. Confirm that the account has access to the spreadsheet and any services the code uses. For a script error, open Extensions > Apps Script and inspect the relevant function; if you did not write the code, ask its owner what it is intended to do before granting access. Testing on a duplicate can help distinguish a code issue from a changed sheet layout.
When another method is a better choice
A macro is not always the simplest solution. If the goal is to calculate a result that updates as data changes, a spreadsheet formula may be more appropriate than a recorded series of edits. If the goal is to highlight values based on rules, conditional formatting can often do that without running a script. For a routine involving buttons, custom menus, multiple steps, or other Google services, a purpose-written Apps Script may be more suitable than a basic recording.
For team processes, consider who will maintain the automation. A short macro that applies a consistent format may be easy to understand and hand over. A script with complex logic needs documentation, testing, and someone who can update it when the spreadsheet changes. If a task is rare, manual steps may be safer than maintaining automation that nobody remembers how to verify.
Frequently Asked Questions
Are Google Sheets macros free?
There is no separate purchase for the built-in macro recorder in Google Sheets. The account and organization using Sheets may determine which services are available, and Apps Script has usage limits and administrative controls that can matter for larger or more complex automations.
Can Google Sheets run Excel VBA macros?
No. Sheets macros use Apps Script, while Excel VBA macros use a different programming environment. An Excel file’s VBA code does not become a working Sheets macro when the file is opened or converted; the automation generally needs to be recreated or rewritten.
Can I edit a recorded macro?
Yes. Open the spreadsheet and choose Extensions > Apps Script to view the attached project. The recorded macro is represented by code that you can inspect or change. Make a copy and test code edits before using them on important data.
Why does Sheets ask me to authorize a macro?
A macro is Apps Script code, and it may need permission to access the spreadsheet or other Google services. Review the authorization request and run the script only if you trust its source and the requested access makes sense for its purpose.
Can a macro work if the spreadsheet layout changes?
It depends on how it was recorded and written. A routine based on fixed cell addresses may target the old locations after rows or columns move. Relative references or edited Apps Script can make some tasks more adaptable, but test the macro against the new layout before relying on it.
Related
- Excel Invoice Copy: How to Duplicate and Reuse Invoices
- Excel Timesheet: How to Add Up Hours Correctly
- Excel Data Model Won’t Open? Causes and Fixes
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- VBA Array Add: How to Append Values and Resize an ArrayVBA has no built-in Array.Add method. To add values, use a dynamic array and resize it with ReDim…
- Excel VBA Font Color: Set, Read, and Fix ItIn Excel VBA, set a cell’s font color with the Font.Color property, usually by assigning an RGB value—for…
- Excel VBA Activate Sheet: Syntax, Examples, and FixesTo activate a worksheet with VBA, reference it by name and call its Activate method: ThisWorkbook.Worksheets("Summary").Activate. The sheet…
- Excel VBA Intersect: Check Whether Cell Ranges OverlapIn Excel VBA, use Application.Intersect to find the cells shared by two or more ranges on the same…
- Excel VBA List Worksheet Names: Methods and ExamplesTo list worksheet names with Excel VBA, loop through the workbook’s Worksheets collection and read each sheet’s Name…
- VBA Loop Backwards: Syntax, Examples, and Common ErrorsTo loop backwards in VBA, start at the highest value, end at the lowest, and use a negative…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.