Yes. Google Sheets supports macros: you can record a sequence of actions and replay it later, or edit the generated Google Apps Script to customize what it does. In a web browser, find the feature under Extensions > Macros; it is useful for repeating routine spreadsheet work, but it is not the same as running Excel VBA macros.
What a Google Sheets macro is
A macro is a saved set of instructions that performs actions in a spreadsheet. Instead of repeatedly applying the same formatting, arranging the same columns, or entering the same structure, you can record the steps once and run them again. A macro acts on the spreadsheet; it is not a spreadsheet formula that calculates a value in a cell.
Google Sheets implements macros through Google Apps Script, Google’s cloud-based scripting platform. When you record a macro, Sheets creates a script function associated with that spreadsheet. You do not need to write code to make a basic recorded macro, although you can open and revise the script if you want to add logic or handle more complex tasks.
For example, imagine a weekly report with a new tab for each week. A macro could apply a standard header style, set number formats, and freeze the top row. You can run those same actions on a new tab instead of repeating each menu choice. The macro follows the steps you recorded; it does not automatically understand what a report means or decide how to handle every possible variation.
How to record a macro
Open the spreadsheet in Google Sheets in a desktop web browser. The recording process is designed for a sequence of actions you can perform through the Sheets interface:
- Choose Extensions > Macros > Record macro.
- Choose whether to use absolute references or relative references when the recording prompt offers that choice.
- Carry out the spreadsheet actions you want to save, such as applying a format or resizing a column.
- Choose Save, give the macro a recognizable name, and optionally assign a shortcut if one is offered.
- To run it later, return to Extensions > Macros and select its name.
Absolute references target the same cell locations used while recording. If you formatted B2:D20, an absolute-reference macro will generally repeat those actions on that same range. Relative references make actions depend on the current selection or position, which can be more useful when you want to repeat a pattern beside or below different data. Consider what will be selected when you run the macro: a reference choice that works for one workflow may be awkward for another.
Keep the first recording short and test it on a copy or a disposable tab. A macro can change cells, formatting, or layout quickly, and running it in the wrong place can produce unwanted edits. If a recorded action is not captured as expected, simplify the sequence or adjust the generated script.
Running, naming, and editing macros
Saved macros appear in the Extensions > Macros menu. Selecting one runs its associated function in the current spreadsheet. A clear name, such as FormatWeeklyReport, is easier to recognize than a default-style label when a file has several macros. If you assign a keyboard shortcut, keep a note of it for people who use the spreadsheet; choosing the menu is a straightforward alternative when you forget the shortcut.
To inspect or change the code, use Extensions > Apps Script. The script project connected to the spreadsheet contains the macro function. Recorded functions can often be edited to change a range, add a condition, or make a repeated action less dependent on a fixed layout. After changing code, save the project and run the macro to check the result. Script changes can affect the spreadsheet, so test them with sample data before relying on them in a live workflow.
Sheets also lets you add eligible Apps Script functions to the macro menu through Extensions > Macros > Import macro. This is useful if a script already contains a function you want to run as a macro. Not every function is necessarily suitable: a macro should be designed to perform an action, and you should understand what the code does before importing or running it.
Tasks macros can and cannot automate
Macros are most effective for stable, repetitive tasks that use a predictable sheet structure. Common examples include applying a standard style, inserting or arranging recurring report elements, and carrying out a familiar series of edits. Apps Script can extend automation beyond the actions captured by the recorder, but that usually requires some scripting knowledge and careful testing.
A macro is not a general-purpose decision maker. If a new report has different columns, missing rows, or unexpected values, a simple recording may still act on the old positions rather than adapting intelligently. For workflows that depend on conditions, variable ranges, or multiple steps of logic, Apps Script can be customized to check the sheet before changing it. The more the task varies, the less likely a basic recording alone is to be reliable.
Macros are also different from formulas and custom functions. A formula calculates a result and displays it in a cell; a macro runs a sequence of actions. For instance, a formula can calculate a total that updates when its inputs change, while a macro might apply a report format when you choose to run it. Use a formula for ongoing calculations and a macro for repeatable actions.
Google Sheets macros versus Excel macros
The word macro is used in both spreadsheet products, but the technologies differ. Google Sheets macros are backed by Apps Script, which uses JavaScript-based code and runs within Google’s services. Excel desktop macros commonly use Visual Basic for Applications (VBA). A VBA macro cannot simply be pasted into Google Sheets and run as a Sheets macro, and Apps Script is not a drop-in replacement for VBA.
That distinction matters when moving a workbook between products. A spreadsheet’s cell values and many formulas may transfer, but automation may need to be rewritten. If a team depends on an existing Excel macro, identify what the code does and whether it relies on Excel-specific features before planning a migration. For new automation, choose the scripting environment that matches where the spreadsheet will actually be used.
Google Sheets is primarily used in a browser and stores its spreadsheet files online. Excel also has desktop, web, and Mac versions, and macro capabilities vary by platform and file type. Excel for the web does not run VBA macros in the same way as desktop Excel. These differences make it important to check the target app and users’ devices rather than assuming a macro will travel with a copied file.
Sharing, permissions, and safety
A macro is attached to the spreadsheet’s Apps Script project, so sharing the spreadsheet also affects who can work with its bound script. People who need to use a macro generally need appropriate access to the sheet, and a user may be asked to authorize a script the first time they run it. The permission prompt depends on what the script is designed to access. Read the prompt and make sure the requested access makes sense for the task.
Do not run code from an unfamiliar spreadsheet just because it contains a macro. A script can do more than format cells if it has been written to interact with other Google services or external resources. Review the script and its requested permissions, especially when the file came from someone you do not trust. In a workplace, an administrator may also set policies that limit Apps Script or related permissions.
Macros are not a secure way to hide sensitive data or restrict who can edit a process. Spreadsheet editors may be able to inspect or alter the connected script. If a sheet is shared broadly, decide whether those people should also be able to change the automation. Keep a clean backup before substantial script edits, and test changes on a copy when the spreadsheet contains important records.
Limits, costs, and common problems
You do not generally buy a separate macro feature to use macros in Google Sheets; they are part of the Sheets and Apps Script environment. However, Apps Script has service quotas and execution limits, and these can differ by account type and service. Limits can change, so check Google’s current Apps Script quota documentation if a script needs to run frequently, process a large amount of data, or connect to other services. A macro that works on a small sheet may need a more efficient script for a larger one.
If a macro does not appear or run as expected, check a few common causes:
- Wrong spreadsheet: Macros are associated with a particular spreadsheet, so opening another file will not necessarily show the same list.
- Unexpected selection: A relative-reference macro may act from the current selection. Select the intended starting cell or range before running it.
- Authorization or policy: Complete a legitimate permission prompt, or ask your administrator whether Apps Script is restricted.
- Changed layout: Inserted columns, renamed tabs, or shifted data can make a recorded sequence unsuitable for the new layout.
- Script error: If code was edited, review the Apps Script editor for errors and test the macro with noncritical data.
Do not assume that running a macro can be reversed with the ordinary Undo command. Script-driven changes may not behave like a single manual edit in the undo history. For valuable data, make a copy first or use version history as a recovery option, and verify the result before continuing with further edits.
Frequently Asked Questions
Can Google Sheets run Excel VBA macros?
No. Google Sheets uses Apps Script for its macros, while Excel VBA is a different technology. VBA code needs to be rewritten or replaced with an approach supported by Sheets.
Can I use macros in Google Sheets for free?
There is no separate macro purchase required for ordinary use of Sheets macros, but account features, administrator policies, and Apps Script quotas can affect what is available or how much a script can do.
Can I create a macro without coding?
Yes. Choose Extensions > Macros > Record macro, perform the actions, and save the recording. Editing the resulting Apps Script code is optional for a basic macro.
Can I run a Google Sheets macro on my phone?
The full macro recording and management workflow is intended for Google Sheets in a desktop web browser. Mobile apps do not provide the same complete interface, so use a browser on a computer to record, edit, or manage macros.
Why does my macro change the wrong cells?
It may use absolute references, depend on a different starting selection, or rely on a layout that has changed. Review the reference option and test the macro on a copy with the same selection and structure you plan to use.
Related
- Excel Time Difference in Seconds: How to Calculate
- Excel Date Without Year: Display a Date Without Its Year
- Excel Time Difference Between Two Dates and Times Explained
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Google Sheets Macros: How to Create, Run, and Edit ThemYes. You can create macros in Google Sheets using its built-in recorder: in a desktop web browser, choose…
- Google Sheets Macros: How They Work and What to KnowYes. Google Sheets supports macros: you can record repeated actions and run them again, or edit the generated…
- VBA Range.Item: How Cell Indexing WorksIn Excel VBA, Range.Item(rowIndex, columnIndex) returns a Range object for the cell at the specified row and column…
- Excel VBA MATCH Error Handling: Avoid Run-Time ErrorsFor safer Excel VBA MATCH error handling, use Application.Match and test its result with IsError before using it.…
- Quick Sort in VBA: Built-In Function or Custom Code?No: VBA does not include a built-in procedure or keyword named QuickSort or quick sort. Call is a…
- Convert Excel Macros to Google Sheets: What Works?Yes, you can move an Excel macro workflow to Google Sheets, but you generally cannot run its VBA…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.