Yes. You can make macros in Google Sheets by recording a sequence of actions in the browser; Sheets saves the macro as Google Apps Script code that you can run again or edit. To start, open a spreadsheet and choose Extensions > Macros > Record macro.
What a Google Sheets macro is
A macro is a saved set of spreadsheet actions that can be replayed to automate repetitive work. For example, you might use one to format a weekly report, apply a standard header style, resize columns, or clean up a data range in the same way each time. Instead of repeating the steps by hand, you run the macro on the relevant sheet.
In Google Sheets, a recorded macro is backed by Apps Script, Google’s cloud-based scripting platform. Recording actions creates a script function associated with the spreadsheet. That means a Sheets macro is not the same technology as a Microsoft Excel VBA macro, even though both can automate spreadsheet tasks.
The recording tool is most useful when the job consists of repeatable actions that you can perform directly in the spreadsheet. It can also give you a starting point for a more customized script. A macro is not a video or a literal replay of mouse movements; Sheets represents recorded work as code that calls spreadsheet services.
How to record a macro
Use Google Sheets in a desktop web browser to record a macro. The exact steps are:
- Open the spreadsheet and select Extensions > Macros > Record macro.
- Choose whether the macro should use absolute or relative references. The difference matters when you run it on a different cell or range.
- Perform the spreadsheet actions you want to save, such as applying a number format, adding a border, or changing a column width.
- Click Save in the recording bar. Give the macro a name, and optionally assign it a keyboard shortcut.
- To replay it, choose Extensions > Macros and select the macro by name.
Keep the first recording small. For example, record a macro that bolds a selected row, applies a background color, and freezes the top row only if freezing is part of the repeated task. Test it on sample data or a copy before relying on it for an important report. A recording may include actions you did not intend to automate, so a short, deliberate sequence is easier to check and maintain.
Absolute and relative references
When you record, Sheets asks how to handle cell references. With an absolute reference, recorded actions target the same cells or range each time. This is useful when a routine always updates a fixed location, such as formatting the title in A1 or clearing a specific input area.
A relative reference makes the macro act in relation to the cell or range that is active when you run it. This is often more useful for repetitive work across rows. Suppose you record a macro that formats the selected row’s date and currency cells. With relative references, you can select a different row before running the macro and apply the same pattern there. If you choose absolute references instead, it may keep returning to the cells used during recording.
Think about where you will start the macro before choosing. If its behavior seems wrong, check the selected cell, the recorded reference mode, and the range used when you made the recording. A macro that applies formatting to the wrong place is often a reference issue rather than a failure to save.
Running, renaming, and sharing macros
You can run a saved macro from Extensions > Macros. If you assigned a keyboard shortcut, Sheets also displays that shortcut in the menu. A shortcut can be convenient for a frequent task, but using the menu is a dependable way to confirm which macro you are about to run.
To change a macro’s name or assigned shortcut, open Extensions > Macros > Manage macros, where the available management options are shown. To inspect or change the underlying code, use the Apps Script editor instead. If you share a spreadsheet, remember that the macro is associated with its script project, and people working with the file may encounter an authorization prompt when they run a script for the first time. Sharing a spreadsheet does not mean every person should automatically trust every script in it.
Macros are tied to the spreadsheet rather than being a general-purpose recording that is automatically installed in every file in your account. If you copy a spreadsheet for a new reporting cycle, check whether the copy contains the script and test the macro there. Also verify that collaborators have the appropriate access to the file and understand what the automation does.
Editing a macro with Apps Script
A recorded macro is a script function, so you can inspect or edit it by choosing Extensions > Apps Script. The editor opens the script project associated with the spreadsheet. The generated code can look technical, but you can still use it to check which sheet, cells, and operations the recording refers to.
Editing is useful when you need to adjust a range, add a condition, or make a macro work beyond the exact steps captured by the recorder. For example, a recording might format a particular range, while a carefully modified script could be designed to locate the relevant data dynamically. That kind of change requires understanding Apps Script; it is not simply a setting in the recorder. Make a copy of the spreadsheet before experimenting, and test changes on data that can be restored.
Apps Script can do more than replay simple formatting, but broader capabilities bring more responsibility. A script may request access to spreadsheet data or other Google services depending on what it does. Read the code and authorization prompt rather than approving permissions automatically, especially if someone else provided the spreadsheet or script.
What macros can and cannot do
Macros are a good fit for stable, repetitive spreadsheet routines. They can save time when the same set of supported actions must be applied over and over, and the recorder avoids having to write code just to capture a basic sequence. They can also serve as a useful first draft if you later want to learn how the corresponding Apps Script works.
They are less suitable when the task depends on complex decisions, changing data layouts, or external systems. The recorder captures actions, not the business rules in your head. If the task is “format the next block only when its status is approved,” a simple recording may not express that decision. You may need to edit the script, use spreadsheet formulas or built-in tools, or choose a different workflow.
- Good candidates: applying a consistent format, repeating a known sequence of edits, or preparing a standard section of a report.
- Possible script work: choosing different actions based on cell values, finding changing ranges, or coordinating with other Google services.
- Poor candidates: tasks that change unpredictably, depend on manual judgment, or involve sensitive data without a clear permission and review process.
Do not assume that recording automates every feature in the Sheets interface. If an action is not captured as expected, check the resulting script and test the macro. Some workflows are better handled by a built-in Sheets feature than by repeating a long recording.
Google Sheets macros versus Excel macros
The word “macro” is used in both products, but the code and compatibility differ. Google Sheets uses Apps Script for its macros. Excel for Microsoft 365 on Windows commonly uses VBA for workbook macros, and Excel also has other automation options. A VBA macro is not directly executable as a Google Sheets macro, and recording a Sheets macro does not create VBA code.
If you upload an Excel workbook containing VBA, do not expect Sheets to run that VBA. Opening or converting a workbook does not translate its automation into Apps Script. To move the automation, you generally need to recreate the workflow using Sheets’ recorder or rewrite the logic in Apps Script, then test it against the converted spreadsheet. Conversely, an Apps Script macro is not a VBA macro that Excel can simply run.
Choose based on where the spreadsheet will live and who needs to use it. Sheets macros suit work that takes place in Google Sheets and is shared through Google Drive. If a team relies on existing VBA, Excel-specific features, or desktop workflows, keeping the process in Excel may be more practical than rebuilding it. When files move between products, check both the data and the automation separately.
Permissions, safety, and cost
There is no separate fee for creating an individual macro inside Sheets, though access to Google Sheets and broader account or organization services can depend on the Google account or Workspace plan. A macro runs as script code, so treat it with the same care as other executable automation. Before running code from a shared file, check who supplied it and what actions it performs.
Authorization prompts are part of how Google Apps Script requests permission for operations that need access to your account or spreadsheet. A prompt is not, by itself, proof that a script is safe. If the requested access seems unrelated to the task, stop and ask the file’s owner or an administrator before proceeding. For work data, follow your organization’s rules for sharing, script approval, and handling confidential information.
Keep a clean original or make a copy before testing a macro that changes many cells. Unlike typing into a cell, a script-driven operation may not be easy to reverse with the normal undo command. For important files, use version history and test on a duplicate before running automation on the live spreadsheet.
Alternatives when a macro is not the right tool
Before recording a macro, consider whether a built-in Sheets feature can solve the problem with less maintenance. For repeated visual styling, conditional formatting can apply formats automatically when values meet criteria. Filters and filter views can make recurring data review easier. Data validation can standardize entries, while formulas can calculate results as new rows are added.
For automation that must run without someone selecting a macro, Apps Script can be developed to respond to supported events or run on a schedule, subject to its permissions and platform limits. That requires script setup rather than merely recording a macro. If the work is a one-time cleanup, a filter, sort, or manual edit may be quicker and easier to verify than building automation.
A practical decision is to ask whether the task is repeated, consistent, and made up of actions Sheets can capture. If all three are true, try a short macro. If the task needs conditions, changes often, or must run automatically, investigate Apps Script or a built-in feature instead.
Frequently Asked Questions
Can I make a macro in Google Sheets without coding?
Yes. Use Extensions > Macros > Record macro, perform the actions, and save. The recorder generates Apps Script code for you. You only need to work with code if you want to inspect or customize what the recording does.
Can I use a Google Sheets macro on my phone?
The macro-recording workflow is designed for Sheets in a desktop web browser. Mobile apps do not provide the same recording and script-editing experience, so create and manage macros in a browser. For a quick task on a phone, use the spreadsheet’s available editing features instead.
Can Google Sheets run an Excel VBA macro?
No. Sheets macros use Apps Script, while Excel VBA uses a different language and environment. You must recreate the steps or rewrite the VBA logic for Apps Script; converting the workbook alone does not convert the macro.
Why does Sheets ask me to authorize a macro?
A macro is Apps Script code, and a script may need permission to access the spreadsheet or other Google services. Review the requested access and make sure you trust the source before authorizing it. Ask your administrator if an organization policy applies.
Can a Google Sheets macro run automatically?
A macro recorded through the menu is normally run by selecting it or using its assigned shortcut. For event-based or scheduled automation, you may need to build or adapt an Apps Script solution and configure an appropriate trigger; that is a separate step from recording a macro.
Related
- Excel Time to Number: Convert Hours, Minutes, and Seconds
- Excel Time Zones: How Date and Time Conversion Works
- Excel Text Across Cells Without Merging
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA: Get the Current Workbook File Path EasilyIn Excel VBA, use ThisWorkbook.Path to get the folder path of the workbook that contains the code, or…
- Excel VBA: Find the Bottom Row of Data in a SheetTo find the bottom row in a particular Excel column, start at the worksheet’s last row and move…
- Excel VBA Day From Date: Weekday Numbers and NamesIn Excel VBA, use Day(dateValue) to return the day of the month, such as 14, and Weekday(dateValue, vbMonday)…
- Excel VBA Exit Sub: How It Works and When to Use ItIn Excel VBA, Exit Sub immediately ends the currently running Sub procedure and returns control to the code…
- Creating Macros in Google Sheets: A Practical GuideTo create a macro in Google Sheets, open the spreadsheet in a web browser and choose Extensions >…
- Excel VBA: Clear the Clipboard After Copy and PasteTo clear Excel’s copy mode after a VBA copy-and-paste operation, run Application.CutCopyMode = False after the paste. This…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.