Yes. You can create macros in Google Sheets using its built-in recorder: in a desktop web browser, choose Extensions > Macros > Record macro, perform the actions you want to repeat, and save the recording. Sheets stores the macro as Google Apps Script, so you can run it again from the menu or edit its script when the recorded steps need more control.
What a Google Sheets macro is
A macro is a saved sequence of spreadsheet actions that you can replay instead of doing the same work by hand. For example, you might apply a standard heading style, format a date column, freeze a row, or arrange a report in a consistent way. The recorder translates supported actions into Apps Script instructions associated with the spreadsheet.
This distinction matters if you are familiar with Excel. A Google Sheets macro is not an Excel VBA macro, and Sheets does not run VBA code. The underlying language is Apps Script, which is based on JavaScript and provides services for working with Google products. You can create a simple macro without writing code, but understanding that it produces a script helps explain permissions, editing, and compatibility.
Macros are useful for repeatable operations, not for every kind of automation. A recorded sequence can save time on routine formatting or cleanup, while a workflow involving decisions, changing data structures, or external services may need custom Apps Script instead.
How to record a macro
Create and record a macro in a Google Sheets file in a desktop browser. The basic process is:
- Open the spreadsheet and select Extensions > Macros > Record macro.
- Choose whether to use absolute references or relative references. The choice affects how cell selections are replayed.
- Carry out the actions you want the macro to repeat, such as applying a number format or setting a fill color.
- Click Save in the recording controls, give the macro a name, and save it. If the dialog offers a shortcut option, you can assign a number for keyboard access.
Keep the recording focused. A short macro that does one predictable job is easier to reuse and troubleshoot than a long recording that includes unrelated clicks. If you accidentally include an action, stop and save only if the result is useful; otherwise discard the recording and start again.
After saving, find the macro under Extensions > Macros. Choose its name to run it. You can also open Extensions > Apps Script to inspect or adjust the generated code. Menu wording or available options can change as Google updates Sheets, so the current menu in your account is the best guide.
Absolute and relative references
The reference setting is one of the most important choices during recording. With absolute references, a recorded action targets the same cells each time. If you record formatting for A2:A20, running the macro later is intended to apply the operation to that same address, rather than shifting it because you selected a different starting cell.
Relative references make recorded cell movements relative to the selected starting point. This is helpful when you need to apply the same sequence to different rows or columns. For instance, if you select the first cell in a new data row and run a macro that formats a cell a short distance to its right, a relative recording can follow that position rather than always returning to a fixed address.
Neither option makes every recorded action universally reusable. A macro may still depend on the active sheet, the layout, or the presence of expected data. Try it on a copy or a small sample before using it on an important range. If results land in the wrong place, check the reference setting and the selection you made before running the macro.
Running, naming, and sharing macros
To run a saved macro, open Extensions > Macros and select it. If you assigned a keyboard shortcut, Sheets displays the shortcut information in the Macros menu. The documented shortcut pattern uses Ctrl+Alt+Shift plus a number on Windows and ChromeOS; on a Mac, use Control+Option+Shift plus the number. Browser or operating-system shortcuts can sometimes interfere, so the menu is a reliable alternative.
Use names that describe the task, such as FormatMonthlyReport or CleanImport. Descriptive names are especially useful when a spreadsheet has several macros. If the macro list becomes confusing, open Apps Script to see the associated functions, but avoid renaming or changing generated code unless you understand the effect.
A macro belongs to the spreadsheet in which it was created. When you share that file with collaborators, editors can work with the spreadsheet and its associated script subject to their access and authorization. A macro is not automatically installed in every spreadsheet in your account. To reuse it elsewhere, you may need to recreate it, copy an appropriate script, or build a reusable Apps Script project.
Editing macros with Apps Script
The recorder is a starting point rather than a limit. From Extensions > Apps Script, you can inspect the generated function and, if you know Apps Script, change its behavior. This can help remove redundant steps, make a process more flexible, or add logic that the recorder cannot express. The editor uses Apps Script, not VBA; Excel VBA code cannot simply be pasted into a Sheets macro and expected to work.
Editing introduces the possibility of coding errors. A small change can cause a function to fail or affect a different range, so preserve a working version and verify changes on sample data. When a macro runs, it may alter cells, formatting, or sheet structure, and those changes may not be reversible with the spreadsheet’s Undo command after the script has executed. Keep a copy of important data before running an unfamiliar or substantially changed macro.
Apps Script can also support broader automation, such as responding to an event or working with other Google services, but that is a separate step beyond recording a macro. Triggers and services have their own setup, authorization, and usage limits. Do not assume that recording a macro automatically makes it run on a schedule or whenever new data arrives.
What macros can and cannot do
For common tasks, macros can save time and reduce small inconsistencies. Useful examples include:
- Applying the same font, colors, borders, and number formats to a report.
- Freezing rows or columns and adjusting a familiar layout.
- Repeating a supported sequence of sorting, formatting, or sheet-editing actions.
- Preparing a recurring export or report where the source sheet follows a stable layout.
The recorder captures supported spreadsheet actions; it does not guarantee that every click or interaction can be replayed. A process that relies on a changing layout, a different sheet name, or a decision based on the contents of a cell may need a more carefully written script. Run the macro in the context for which it was designed and confirm the result, especially after someone changes the spreadsheet structure.
Macros also do not turn a Google Sheets file into a VBA-enabled Excel workbook. If you download the spreadsheet as an Excel file, the Google Sheets macro is not converted into a working VBA macro. A move between Sheets and Excel may require rebuilding the automation with the destination program’s tools.
Access, cost, and safety
There is no separate macro purchase required to use the built-in recorder in an account that has access to Google Sheets. Sheets is available through personal Google accounts and Google Workspace, although Workspace features, account administration, and service limits can depend on the plan and organization. Apps Script also applies quotas and authorization rules; these can matter more as an automation becomes complex or runs frequently.
Because a macro is a script, treat it with care. When a script needs access beyond the spreadsheet, Google may show an authorization screen describing the requested permissions. Read the prompt and consider whether those permissions match the task before approving. Do not run a script from an unfamiliar source simply because it is attached to a spreadsheet you received.
For a macro you created yourself, keep the requested access proportionate to what it does. For shared workbooks, make sure collaborators understand what the macro changes and who is allowed to edit the associated script. A backup copy is a simple safeguard when a macro will modify substantial or business-critical data.
Common problems and alternatives
If Extensions or Macros is missing, first confirm that you are working in Google Sheets in a desktop browser and that you have permission to edit the file. A Microsoft Excel file opened in compatibility mode may need to be converted to Google Sheets before you can use Sheets-specific features. Mobile apps are not the place to create or manage recorded macros; use the browser version on a computer for the recording and script editor.
If a macro runs but changes the wrong cells, check whether it was recorded with absolute or relative references and what cell or range is selected when you start it. If it does nothing or reports an error, confirm that the expected sheet and data layout still exist, then inspect the associated function in Apps Script. A renamed tab or reorganized columns can make an old workflow unsuitable.
For a one-time task, using Sheets’ normal menus may be simpler than recording a macro. For recurring tasks that need conditions or custom behavior, Apps Script offers more flexibility. If your team works in Excel instead, Excel’s macro tools and VBA are the relevant options; Microsoft 365 also has Office Scripts for certain web-based workflows. These are different systems, and code or recordings generally need adaptation rather than direct transfer.
Frequently Asked Questions
Can you make a macro in Google Sheets without coding?
Yes. Use Extensions > Macros > Record macro, perform supported actions, then save the recording. The recorder generates Apps Script behind the scenes, but basic recording and playback do not require you to write that code.
Can I use an Excel VBA macro in Google Sheets?
No. Google Sheets does not run VBA. Its recorded macros use Apps Script, so an Excel macro needs to be rewritten or replaced with a Sheets workflow; converting the workbook does not translate VBA into Apps Script automatically.
Can a Google Sheets macro run automatically?
A recorded macro normally runs when someone selects it or uses its assigned shortcut. Automatic execution requires additional Apps Script setup, such as an appropriate trigger, and may require permissions. Recording a macro alone does not schedule it.
Why does my macro affect the wrong cells?
It may have been recorded with absolute references, which target fixed addresses, or relative references, which shift from the selected starting position. Check the recording choice, your active selection, and whether the sheet layout has changed.
Can I create or run macros in the Google Sheets mobile app?
Use Google Sheets in a desktop web browser to record and manage macros and open the Apps Script editor. The mobile app does not provide the same macro-recording workflow, so switch to a computer for those tasks.
Related
- How to Copy Excel Cells to Word Without Losing Format
- Copy a Word Document into Excel: Best Methods and Tips
- Copying Text from Excel to Word: Formatting, Links and Tables
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA: Find the Last Column in a Sheet or RangeTo find the last nonempty column in a specific row, start at the worksheet’s last column and move…
- Excel VBA Array Delete: How to Remove Items SafelyIn Excel VBA, use Erase to clear an entire array; it does not remove just one element. To…
- Excel VBA Copy and Paste Values OnlyTo copy a range in Excel VBA and paste only its values, use Copy followed by PasteSpecial Paste:=xlPasteValues.…
- Excel VBA: Check If AutoFilter Is Active on a SheetIn Excel VBA, check Worksheet.AutoFilterMode to find out whether AutoFilter arrows are displayed, and check Worksheet.FilterMode to find…
- Excel VBA Find Last Row: Reliable Methods and ExamplesIn Excel VBA, find the last row in one column with Cells(Rows.Count, "A").End(xlUp).Row, replacing A with the column…
- VBA Range Index: How Cells, Item, and Offsets WorkIn VBA, a range index identifies a cell by its row and column position, starting at 1. For…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.