Yes. Macros work in Google Sheets in a web browser: you can record a sequence of spreadsheet actions and replay it later, while Google Sheets saves the macro as Apps Script code attached to that spreadsheet. They are useful for repeating routine edits, but they do not automatically understand new data or run every action a person can perform.
What a Google Sheets macro is
A macro is a saved set of steps that you can run again instead of repeating them manually. For example, you might record formatting a report header, applying a number format, and resizing a column. When the next report arrives, you can run the macro to repeat those operations.
In Google Sheets, a recorded macro is not a separate recording file. Sheets translates the recorded actions into a function in an Apps Script project associated with the spreadsheet. Apps Script is Google’s JavaScript-based scripting platform, and the spreadsheet service lets scripts work with cells, sheets, and other spreadsheet features.
This distinction matters: a macro can be replayed as recorded, and someone with the right access can inspect or edit its underlying code. It is more than a button that stores a visual sequence, but it is not automatically a smart workflow that detects what your data means.
How to record and run a macro
To create one, open the spreadsheet in Google Sheets in a browser. Select Extensions > Macros > Record macro. Carry out the actions you want to repeat, then use the recording panel to save the macro. Sheets asks whether the macro should use absolute or relative references; that choice affects how it treats cell locations when you run it.
- Open the spreadsheet and choose Extensions > Macros > Record macro.
- Choose absolute or relative references, then perform the steps to capture.
- Click Save, give the macro a name, and save it.
- Run it later from Extensions > Macros and select its name.
The first time a script runs, Google may ask you to review and authorize the access it needs. Read the authorization prompt before continuing. The exact prompt depends on the script and the services it uses. If the macro does not appear in the menu after recording, confirm that you saved it and that you are in the spreadsheet where it was created.
Absolute versus relative references
Absolute references repeat an action at the same cell locations used during recording. If you recorded formatting cells A1:D1, an absolute-reference macro will target those cells again when run, even if you select a different starting cell. This is appropriate when the report layout is fixed and the same range needs attention every time.
Relative references make recorded cell actions depend on the selected starting cell. If you record an operation on a cell one row below your selection, then run the macro with another cell selected, the operation can apply at the corresponding offset from the new selection. This is useful when working through similar blocks or rows in different parts of a sheet.
Neither choice is universally better. Test the macro on a copy or on disposable data first, especially if it changes values, deletes content, or modifies a large range. The reference mode helps control where actions apply; it does not make the macro detect the boundaries of a table or decide which records are relevant.
What macros can and cannot automate
Macros are well suited to repeatable spreadsheet operations that the recorder can capture. Common examples include applying consistent formatting, setting a column width, inserting or removing rows, and carrying out other supported menu or cell actions. A macro can make a recurring report look consistent without requiring you to remember every click.
- Good fit: a weekly report always needs the same header style and number format.
- Good fit: a recurring sheet needs a standard sequence of cleanup actions on a known layout.
- Less suitable: a task must identify changing data conditions, make decisions, or adapt to unpredictable table shapes.
- Not a direct fit: running Excel VBA code. Google Sheets macros use Apps Script, not VBA.
A recorded macro usually repeats instructions rather than interpreting your goal. If you recorded a sort on a particular range, the macro does not necessarily know that next month’s table has extra columns or rows. Similarly, it will not infer that a newly added status value should be treated differently. For logic that needs conditions, variable ranges, custom prompts, or integrations, editing the Apps Script or choosing another tool may be more appropriate.
Editing a macro and using Apps Script
After recording, you can inspect the generated code by choosing Extensions > Apps Script. The project includes a function for the macro. This gives you a route to refine the recorded steps, add logic, or build a more tailored automation, provided you are comfortable working with code. A macro can also be recorded first and then adjusted rather than written entirely from scratch.
For example, a recorded formatting routine may repeatedly target a fixed range. A script developer could revise the code so it locates a data range or checks a condition before changing cells. Those changes require care: incorrect code can alter or remove spreadsheet data, and a script may request broader permissions if it uses additional Google services.
Apps Script has execution and service limits that can vary by account type and use. A short formatting macro is unlikely to present the same demands as a large script that processes extensive data or calls external services. If an automation is business-critical or runs into errors, check Google’s current Apps Script documentation for the applicable limits rather than assuming a macro can run indefinitely.
Sharing, authorization, and safety
A macro belongs to the spreadsheet’s bound Apps Script project, so it is associated with that file rather than being a universal feature installed in every sheet. People who can edit the spreadsheet may be able to work with its attached script, subject to Google’s sharing and script-access rules. A person who runs a script may need to authorize the permissions it requests.
Before running a macro in a spreadsheet someone else shared with you, inspect the project if you are unsure what it does. Open Extensions > Apps Script and review the code, especially if it requests access that seems unrelated to the task. A macro that formats cells should not need a convincing reason to access unrelated services. Do not authorize a script simply because it is labeled as a macro.
Keep a copy of important data before running an unfamiliar or destructive automation. Unlike a simple formatting change, script actions may not be recoverable with the ordinary undo command. Good practice includes testing with a duplicate, limiting access to trusted editors, and documenting what a macro changes so collaborators know what to expect.
Common problems and practical fixes
If a macro fails or produces an unexpected result, start with the selection and the layout. A relative-reference macro may use a different starting cell than you intended, while an absolute-reference macro may keep targeting the original range. Check that the sheet still has the structure used when the macro was recorded and that the relevant cells are not protected against editing.
- The macro is missing: confirm you are in the correct spreadsheet and look under Extensions > Macros. A macro saved in one file is not automatically available in another.
- It changes the wrong cells: check the reference mode and selected starting cell, then test on a copy.
- Google requests permission: review the requested access and authorize only if you trust the script and understand why it needs that access.
- The result is incomplete: compare the current sheet layout with the one used for recording; the macro may rely on fixed ranges or a particular sequence.
- The macro cannot perform a desired action: inspect the generated script or consider Apps Script, a formula, or a manual step instead.
Also distinguish a macro error from a spreadsheet formula error. A macro replays operations; it does not repair broken formulas or guarantee that source data is accurate. If a report still shows an incorrect total after formatting runs correctly, investigate the formula and underlying data separately.
Google Sheets macros compared with Excel macros
The word macro is used in both Google Sheets and Microsoft Excel, but the systems are not interchangeable. Google Sheets macros are implemented with Apps Script. Excel’s traditional macros commonly use VBA, and Excel for the web does not run VBA macros. Excel also offers Office Scripts in supported Microsoft 365 environments, but those are a different automation technology.
As a result, an Excel workbook’s VBA macro will not simply run in Google Sheets, and a Sheets macro will not run as VBA in Excel. Moving a workflow between products usually means rebuilding and checking the automation in the destination tool. The spreadsheet data may transfer, but the code and supported features need separate attention.
Choose based on where the work happens and what the automation must do. If collaborators use Google Sheets and the task is a repeated sequence of supported edits, a Sheets macro may be enough. If a workflow depends on existing VBA, Excel may be the more direct environment. If the task involves rules, integrations, or changing data structures, compare Apps Script with the automation options available in your organization before committing.
Frequently Asked Questions
Are Google Sheets macros the same as Apps Script?
They are closely related, but not identical terms. A Sheets macro is a recorded workflow that Sheets stores as a function in an Apps Script project. You can inspect or modify that code in the Apps Script editor.
Can Google Sheets macros run automatically?
You can run a macro from the spreadsheet’s Extensions > Macros menu. More advanced automatic behavior can be built with Apps Script triggers, but that requires scripting and appropriate authorization; recording a macro alone does not make it run on a schedule.
Can I use an Excel VBA macro in Google Sheets?
No. Google Sheets does not execute VBA. Its macros use Apps Script, so a VBA-based process must be rewritten or replaced with a compatible workflow.
Do macros work in the Google Sheets mobile app?
The macro recording and Apps Script editing workflow is designed for Google Sheets in a web browser. For creating, configuring, or troubleshooting a macro, use the browser interface rather than assuming the mobile app provides the same tools.
Are Google Sheets macros free?
There is no separate charge just to use the basic macro feature in Sheets, but access to Google Sheets depends on your Google account or Workspace arrangement. Apps Script services can also have usage limits, so check current account terms and Google documentation for a particular workload.
Related
- Excel Time Difference Between Two Dates and Times Explained
- Power Query Get Current Year: M Code and Refresh Tips
- Power Query Data Types: Choosing, Changing, and Fixing Them
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA Array Filter: Methods, Code, and ExamplesTo filter a one-dimensional array of strings in Excel VBA, use the built-in Filter function, for example Filter(names,…
- Refresh Pivot Table Using VBA: Code and TipsTo refresh a PivotTable with VBA in Excel for Microsoft 365 on Windows, call its RefreshTable method; to…
- VBA Error Handler: How On Error Works and When to Use ItIn VBA, an error handler is code that responds when a statement fails while a procedure is running.…
- Excel VBA Get Username: Windows or Excel User Name?In Excel VBA on Windows, use Environ$("USERNAME") to read the current Windows account name. Use Application.UserName instead if…
- Excel VBA Find Cell: Code, Options, and ExamplesIn Excel VBA, use the Range.Find method to locate a cell containing specified text or a value. Set…
- How to Create a Pivot Table Using VBA in Excel 365To create a PivotTable with VBA in Excel for Microsoft 365 on Windows, put your source data on…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.