Google Sheets Macros: How They Work and What to Know

VBA & macros · Updated November 3, 2026

Google Sheets Macros: How They Work and What to Know

Yes. Google Sheets supports macros: you can record repeated actions and run them again, or edit the generated Google Apps Script code. Sheets macros are not Excel VBA macros, so an Excel macro cannot simply be run in Google Sheets.

What a macro means in Google Sheets

A macro is a saved sequence of spreadsheet actions, such as applying a format, adding a formula, or resizing columns. Instead of repeating those actions by hand, you run the macro to repeat them. This is useful for routine work in a spreadsheet that follows a consistent layout, such as preparing a weekly report or formatting a data export.

Behind the scenes, Google Sheets turns a recorded macro into a function in Google Apps Script, Google’s JavaScript-based scripting platform. The script is associated with the spreadsheet, and you can inspect or change it in the Apps Script editor. You can also write a script yourself and make its function available as a macro.

The practical distinction is that Sheets offers macro automation, but it does not run VBA. A macro recorded in Excel may use VBA features and Excel-specific objects that have no direct equivalent in Sheets. Moving a workbook to Sheets may require rebuilding its automation with Apps Script.

How to record a macro

Recording is the quickest way to automate a sequence of supported actions in the Sheets web interface. Open the spreadsheet in a browser and use the menu path Extensions > Macros > Record macro. Then carry out the actions you want captured.

  1. Open the spreadsheet and select Extensions > Macros > Record macro.
  2. Choose whether the macro should use absolute or relative references. This choice affects how cell and range selections behave when you run it.
  3. Perform the steps to capture, such as selecting a range and applying a number format or setting a column width.
  4. Select Save, give the macro a name, and confirm. Sheets adds the recorded function to the spreadsheet’s Apps Script project.

For example, you might record selecting a report’s header row, applying bold text, and adding a background color. When the report has the same structure each week, running the macro can repeat those formatting actions. Recording is most useful when the task is a stable sequence of supported Sheets operations; it is not a general-purpose recorder for everything you do on your computer.

Running, managing, and assigning macros

After saving a macro, run it from Extensions > Macros and choose its name. Sheets may ask you to authorize the script the first time it runs. Read the authorization prompt and grant access only if you trust the spreadsheet and understand why the script needs it.

To change a macro’s assigned shortcut or other macro settings, open Extensions > Macros > Manage macros. The available shortcut assignments are intended for running macros in Sheets; they do not make the macro available as an Excel keyboard command. Shortcuts can also depend on browser and operating-system behavior, so use the menu if a shortcut conflicts with another command.

Macros are connected to their spreadsheet rather than being a universal personal macro library. If you need a similar macro in another file, you can create or copy appropriate Apps Script code and configure it there. The menu also offers Extensions > Macros > Import for adding eligible functions from the spreadsheet’s script project to the macro list.

Absolute and relative references

The recording choice matters when a macro selects cells. With an absolute reference, the recorded action targets the same cell or range each time. If a macro formats cells A1:D1, running it while you are looking at another row will still target A1:D1. That is suitable for a fixed title or a designated summary area.

A relative reference makes the action depend on the starting position. For instance, if you record an action that formats the row next to the selected cell, relative behavior can let you repeat that action in other parts of the sheet. This can help when processing similar blocks of data, but it also means you must begin from the intended location.

Before relying on either setting in a live report, test the macro on a copy or on a small sample. Check exactly which cells it changed. A macro can faithfully repeat an unsuitable selection as easily as it can repeat a useful one.

Editing the generated Apps Script

To inspect or customize a recorded macro, choose Extensions > Apps Script. The editor shows the script project associated with the spreadsheet. A recorded macro appears as a function, and the macro menu can run functions that are set up as macros. The generated code can be useful as a starting point, but it may be more verbose than a hand-written script.

Editing code gives you options beyond recording, such as adding conditions or processing a range based on its contents. It also requires care: a script can change or clear data, and a coding mistake can affect more cells than intended. Save your changes and test them with noncritical data before using them on an important sheet.

Apps Script is not identical to JavaScript running in a normal webpage. It provides services for working with Google products, including Sheets, and its available permissions and execution limits depend on the service and account context. A script that accesses other files or services may need additional authorization, while a simple formatting macro may need less.

How Google Sheets macros differ from Excel macros

Excel macros are commonly written in Visual Basic for Applications (VBA), while Google Sheets macros use Apps Script. The two platforms have different programming languages, APIs, file formats, and automation environments. A macro-enabled Excel file can contain VBA, but Sheets does not execute that VBA as a Sheets macro.

When bringing an Excel workbook into Sheets, its cell data and many familiar formulas may transfer, but VBA automation should not be assumed to work. Some Excel features also behave differently or are unsupported in Sheets. If a workflow depends on an Excel macro, identify what it does first, then decide whether to recreate the steps using a recorded Sheets macro, Apps Script, or a different tool.

There is a related misconception that recording a Sheets macro creates a separate binary macro file. Instead, the recorded automation is Apps Script connected to the spreadsheet. That connection makes it convenient to keep automation with a particular file, but it also means sharing and permissions for the spreadsheet and its script matter.

Common problems and practical fixes

  • The macro menu is missing or unavailable: Confirm that you have the spreadsheet open in a web browser and that your account can use Apps Script. A Google Workspace administrator may restrict Apps Script or related features. Ask the administrator if the setting is managed by your organization.
  • The macro changes the wrong cells: Review whether it was recorded with absolute or relative references, and check where you start before running it. Test the action on a copy.
  • The script asks for permission or reports an authorization error: A first run may require approval, and a later code change can require new authorization. Do not approve a prompt for a script you do not trust.
  • The macro runs but does not repeat every step: A recording only captures supported spreadsheet actions. Recheck the saved sequence, and use Apps Script for logic or actions the recorder cannot represent.
  • A copied or converted file behaves differently: Check that the script is present and available in the destination file. Excel VBA does not become Apps Script through conversion.

Safety, sharing, and cost

Treat a spreadsheet macro like code, not merely like formatting. A script may read or modify spreadsheet data, and more capable scripts can request access to other Google services. Before running a macro in a file from someone else, consider whether you trust its owner and script. Review the code in Extensions > Apps Script if you have the knowledge to assess it, and avoid authorizing access that does not fit the task.

Sharing a spreadsheet does not mean every recipient has the same ability to edit its script or authorize it. What a person can do depends on their access, account, and any organization-level controls. For a team workflow, make ownership and maintenance clear: document what the macro changes, who is responsible for it, and whether the team should test code updates before using them.

There is no separate charge just to record a basic macro in Sheets, but access to Sheets and Apps Script can depend on the account and organization. Apps Script also has service-specific quotas and limits, which can vary by account type and change over time. A small formatting macro is different from a script that processes large datasets or contacts external services, so check current Google documentation for limits relevant to a larger automation.

When to use a macro instead of another tool

A macro is a good fit when the same person or team repeatedly performs a predictable sequence in one spreadsheet. It can reduce manual repetition, but it is not always the best way to solve a spreadsheet problem.

  • Use formulas when the result should update automatically as data changes, such as calculating totals or categorizing rows.
  • Use conditional formatting for visual rules that should respond automatically to cell values.
  • Use a recorded macro when a repeatable set of manual actions is the main task, such as applying a standard report layout.
  • Use Apps Script when the workflow needs branching logic, custom menus, or scheduled or event-based behavior. Triggers have their own setup and authorization considerations.
  • Use an add-on or another system when a workflow needs a supported integration or service that a simple macro cannot provide.

Choosing the simplest suitable option makes maintenance easier. If a formula can keep a value current automatically, rerunning a macro by hand may add unnecessary work. If the workflow is a long, conditional process, a short recording may be difficult to maintain and a deliberately designed script may be clearer.

Frequently Asked Questions

Can Google Sheets run Excel VBA macros?
No. Google Sheets macros use Apps Script, not VBA. Excel automation generally needs to be rewritten for Sheets or kept in an environment that supports the original VBA.

Where do I find macros in Google Sheets?
In a browser, open Extensions > Macros to record, run, or manage macros. Use Extensions > Apps Script to view or edit the associated script.

Can I record a macro in the Google Sheets mobile app?
The macro-recording workflow described here is in the Sheets web interface. For creating and managing macros, use Sheets in a desktop browser rather than relying on the mobile app.

Can a Google Sheets macro run automatically?
A macro selected from the menu is run on demand. Apps Script can also use triggers for some event-based or scheduled workflows, but setting up a trigger is a separate scripting task and may require authorization.

Are Google Sheets macros free?
Recording and running a basic macro does not have a separate macro fee. Account access, administrator policies, and Apps Script quotas can affect what you can use, especially in managed Workspace accounts or more complex scripts.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.