Yes. Google Sheets has macros that can record repeated actions and replay them later; unlike Excel macros, Sheets macros are implemented with Google Apps Script rather than VBA. You can record one from Extensions > Macros > Record macro, save it in the spreadsheet, and run it from the Macros menu.
What a macro means in Google Sheets
A macro is a saved sequence of spreadsheet actions that you can run again instead of repeating them manually. For example, if you regularly format a report, you could record actions that bold the header, apply a fill color, resize columns, and set a number format. Later, the macro can repeat those supported actions in a sheet.
In Google Sheets, a recorded macro is a function in an Apps Script project associated with the spreadsheet. Apps Script is Google’s cloud-based scripting platform, based on JavaScript. That connection is important: macros can be more than a simple playback of clicks, because a person comfortable with code can inspect and extend the generated script. However, the recording tool itself is intended to make basic automation possible without writing code.
Macros are saved with the Google Sheets file, not as a separate desktop macro file. They are most useful for predictable, repeatable work inside a spreadsheet. They are not a general-purpose screen recorder, and a recorded sequence will not automatically understand every future variation in the data.
How macro recording works
When you record a macro, Sheets observes supported actions you take and translates them into Apps Script instructions. When you run the saved macro, those instructions perform the recorded operations again. The recorder offers two reference styles, which affect how the actions apply:
- Use absolute references: Actions target the same cell addresses used while recording. If you formatted B2:D2, a later run targets B2:D2 again.
- Use relative references: Actions are applied in relation to the cell or range selected when the macro runs. This is useful when the same operation should be repeated at different locations.
Choosing the wrong reference style can make a macro appear to work while affecting the wrong cells. If you record formatting for a particular report area, absolute references may be suitable. If you want to apply the same cleanup to whichever range you select, relative behavior may be a better starting point. Review the result on a copy or a small sample before relying on a macro in a live workbook.
The recording process captures actions, not the reason behind them. It does not infer that a column is a date column or decide that a new row should be included just because its contents resemble earlier rows. For variable data, you may need to edit the generated script or choose a different automation method.
How to create and run a macro
Use Google Sheets in a web browser and open the spreadsheet where you want the macro. The basic process is:
- Choose Extensions > Macros > Record macro.
- Choose absolute or relative references when prompted.
- Perform the actions you want recorded, such as applying a format or entering a formula.
- Finish the recording and save the macro with a name. Sheets may also offer a keyboard shortcut as part of the save options.
- To use it later, choose Extensions > Macros and select the saved macro.
Make the recording deliberate. Avoid extra clicks and test actions, since any supported action captured during recording may become part of the replay. A useful first macro is a small formatting routine rather than a long sequence that changes many sheets. If the result is not right, revise the recording or inspect its script instead of repeatedly running an uncertain version.
When a macro is run for the first time, Google may ask for authorization because the script is acting on your behalf. Read the permission request and confirm that you trust the spreadsheet and its script before allowing access. The precise prompt depends on what the script does and the permissions it needs.
What macros can do—and where they fall short
Recorded macros are a practical fit for repetitive, fairly consistent spreadsheet operations. Depending on the actions supported by the recorder, they can help with tasks such as applying standard formatting, inserting or editing formulas, and carrying out routine sheet changes. They can reduce repetitive work, but they do not replace careful review of the underlying data.
The key limitation is that recording repeats operations; it does not automatically create robust rules for every possible situation. A macro recorded while a report has 30 rows may not handle a future report with 300 rows as intended if the recorded actions target a fixed range. Likewise, a recorded sort or format operation may depend on the selected cells and the layout at the time it runs.
Macros also do not make Google Sheets a VBA-compatible version of Excel. Excel VBA procedures, forms, and other VBA code cannot simply be run as Sheets macros. If an Excel workbook contains VBA, importing or converting it to Google Sheets does not transform that code into Apps Script. The automation generally needs to be rebuilt in Apps Script or kept in Excel.
For work involving complex decisions, data from external services, scheduled jobs, or custom interfaces, Apps Script can be extended beyond what the recorder captures. That requires code and more attention to authorization, errors, and maintenance. A macro is a convenient entry point, not a guarantee that a complex workflow can be automated safely without programming.
Editing a macro with Apps Script
Because a recorded macro becomes Apps Script, you can open Extensions > Apps Script to view the project associated with the spreadsheet. The generated function is JavaScript-based code. Someone who understands Apps Script can adjust ranges, add conditions, handle data of changing sizes, or make a reusable helper function. The generated code can also help a learner see how spreadsheet actions map to script operations.
Editing code requires more care than recording clicks. A small change can affect a different range or produce a different result, and code may need updates if the spreadsheet layout changes. Keep a copy of important data before running a substantially edited script. Also remember that the script may request permissions beyond the basic spreadsheet actions if you add features that access other Google services or external resources.
Scripts attached to a spreadsheet are often called container-bound scripts. They are connected to that particular file, which makes them convenient for automations that belong with one shared spreadsheet. If you want to reuse the same code across many files or build a larger automation, Apps Script offers other project arrangements, but those are a step beyond simply recording a macro.
Google Sheets macros compared with Excel macros
Both products offer ways to automate repetitive spreadsheet work, but their macro systems are different. Excel’s traditional macro language is VBA, commonly used in desktop Excel. Google Sheets uses Apps Script. The languages, object models, execution environments, and file handling are not interchangeable.
- Where they run: Sheets macros run through Google Sheets and Apps Script. Excel VBA macros are generally associated with desktop Excel, though Excel for the web has limited macro-related capabilities and does not run VBA macros.
- How they are created: Sheets can record actions through its macro recorder and generate Apps Script. Excel has its own macro recorder and VBA editor, with features that depend on the Excel version and platform.
- What happens to existing code: A VBA macro is not converted into an Apps Script macro just by uploading an Excel file to Drive or opening it in Sheets. The automation must be recreated or the workbook used in an environment that supports its VBA code.
- Sharing and execution: Sheets automation is tied to Google Drive access and Apps Script authorization. Excel macro behavior depends on the workbook format, the Excel application, and the user’s macro security settings.
Choose the platform based on the workbook and the people who need to use it. If the organization relies on existing VBA, Excel is usually the more direct fit. If collaborators work in browser-based Sheets and need simple repeatable actions, a Sheets macro may be more convenient. When moving between platforms, plan for a conversion or rewrite rather than assuming the macro will travel with the data.
Sharing, permissions, and safety
A macro can change spreadsheet contents, so treat it as executable automation rather than as harmless formatting. Before running a macro in a file someone sent you, consider whether you trust the file’s owner and understand what the script is intended to do. If a macro’s behavior is unclear, inspect it in Apps Script or ask the owner before granting permissions.
Sharing the spreadsheet gives collaborators access to the file, but each person’s ability to run a script can depend on their access, the script’s requested permissions, and Google Workspace settings. A collaborator may see an authorization prompt the first time they run an automation. In a managed workplace or school account, an administrator may restrict Apps Script or certain services, so a feature that works in a personal account might not be available to every user.
Keep a clean copy or version history point before using a macro that changes many cells. The practical risk is not limited to malicious code: a legitimate macro can overwrite values, format the wrong range, or repeat an unintended action. Test on sample data, and check the resulting cells before sharing the updated file or using it for a consequential process.
Common issues and alternatives
If a macro is missing from the menu, first confirm that you opened the correct spreadsheet and that the macro was saved in that file. If it runs but affects unexpected cells, check whether it was recorded with absolute or relative references and what cells are selected when it runs. If it stops or asks for access, review the authorization prompt and any account or administrator restrictions.
For a simple task, a built-in Sheets feature may be easier to maintain than a macro. Conditional formatting can highlight values automatically, filters and filter views can organize data without replaying clicks, and formulas can calculate results as rows change. For example, a repeated cleanup that only standardizes number display might be handled by applying a number format to a suitable column rather than recording a macro every time.
Apps Script is the natural next step when the workflow needs conditions or needs to work across changing data. Other options include Google Workspace add-ons and integrations with external automation services, subject to their permissions, availability, and any costs. Prefer the simplest method that reliably handles the task: built-in features for standard spreadsheet behavior, a recorded macro for repeatable fixed actions, and custom scripting when the workflow genuinely needs more logic.
Frequently Asked Questions
Are Google Sheets macros the same as Excel macros?
No. Google Sheets macros use Apps Script, while traditional Excel macros use VBA. They do not run each other’s code without being rewritten or otherwise adapted.
Can Google Sheets record a macro without coding?
Yes. Use Extensions > Macros > Record macro, perform the supported actions, and save the recording. The saved macro is still represented by Apps Script behind the scenes, but basic recording does not require you to write code.
Can I use an Excel VBA macro in Google Sheets?
Not directly. Uploading or converting a workbook does not convert VBA into Apps Script. You can recreate the automation in Apps Script or continue using Excel for a workbook that depends on VBA.
Can a Google Sheets macro run automatically when data changes?
A recorded macro is normally run by a user from the Macros menu or its assigned shortcut. More advanced automatic behavior may be possible with Apps Script triggers, but that requires configuring a script and understanding its authorization and trigger limitations.
Do Google Sheets macros work in the mobile app?
Macro recording and the Apps Script editor are designed around the browser version of Sheets. For creating, editing, and reliably managing macros, use Sheets in a desktop web browser rather than relying on the mobile app.
Related
- Data Cleaning in Excel: Practical Techniques That Work
- Data Cleaning Steps in Excel: A Practical Guide
- Outlook Excel Import: Move Spreadsheet Data Safely
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA: How to Find the Next Empty Cell in a ColumnTo find the next empty cell below the last entry in an Excel column, use VBA’s End(xlUp) navigation…
- VBA Macros in Google Sheets: What Works InsteadNo. Google Sheets cannot run VBA macros: VBA is Microsoft Excel’s programming language, and Sheets uses Google Apps…
- Outlook VBA: How to Pull and Export Mail DataTo pull mail data with VBA, use classic Outlook for Windows’ object model to select a folder, loop…
- Excel VBA Active Pivot Table: How to Find and ControlIn Excel VBA, get the PivotTable associated with the active cell by using ActiveCell.PivotTable; Excel does not provide…
- Excel VBA: Find a Cell with Specific Text in a RangeTo find a cell containing specific text with Excel VBA, use the Range.Find method. Set options such as…
- Delete Rows From an Input Range in VBATo delete worksheet rows covered by a range you select in Excel VBA, use Application.InputBox with Type:=8, then…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.