Stay organized with collections Save and categorize content based on your preferences.
Google Sheets lets you record macros that duplicate a specific series of UI interactions that you define. Once you've recorded a macro, you can link it to a keyboard shortcut in the form Ctrl+Alt+Shift+Number
. You can use that shortcut to quickly execute the exact macro steps again, typically in a different place or on different data. You can also activate the macro from the Google Sheets Extensions > Macros menu.
When you record a macro, Google Sheets automatically creates an Apps Script function (the macro function) that replicates the macro steps. The macro function is added to an Apps Script project bound to the sheet, in a file titled macros.gs
. In the event that there is already a project file bound to the sheet with that name, the macro function is appended to it. Google Sheets also automatically updates the script project manifest, recording the name and keyboard shortcut assigned to the macro.
Since every recorded macro is defined entirely within Apps Script, you can edit them directly within the Apps Script editor. You can even write macros from scratch in Apps Script, or take functions you've already written and turn them into macros.
Creating macros in Apps ScriptYou can take functions written in Apps Script and use them as macro functions. The easiest way to do this is by importing an existing function from the Google Sheets editor.
Alternatively, you can create macros within the Apps Script editor by following these steps:
You can edit macros attached to a sheet by doing the following:
If there is already a script bound to a sheet, you can import a function in the script as a new macro and then assign it a keyboard shortcut. You can do this by editing the manifest file and adding another element to the sheets.macros[]
property.
Alternatively, follow these steps to import a function as a macro from the Sheets UI:
The following manifest file example snippet shows the section of a manifest that defines Google Sheets macros. The sheets
section of the manifest defines the name and keyboard shortcut assigned to the macro and the name of the macro function.
sheets
relate directly to Sheets functionality. This example is just a portion of a full manifest file and is not a fully functional manifest.
{
...
"sheets": {
"macros": [{
"menuName": "QuickRowSum",
"functionName": "calculateRowSum",
"defaultShortcut": "Ctrl+Alt+Shift+1"
}, {
"menuName": "Headerfy",
"functionName": "updateToHeaderStyle",
"defaultShortcut": "Ctrl+Alt+Shift+2"
}]
}
}
See the Sheets macro manifest resource for more details on how Sheets macro manifests are constructed.
Best practicesWhen creating or managing macros in Apps Script, it is recommended that you adhere to the following guidelines.
There are a few restrictions on what you can do with macros:
Use macros outside bound scriptsMacros are defined in scripts bound to specific Google Sheets. Macro definitions are ignored if defined in a standalone script or web app.
Define macros in Sheets add-onsYou cannot distribute macro definitions using a Sheets add-on. Any macro definitions in a Sheets add-on project are ignored by users of that add-on.
Distribute macros in script librariesYou cannot distribute macro definitions using Apps Script libraries.
Use macros outside of Google SheetsMacros are only a feature in Google Sheets, and do not exist for Google Docs, Forms, or Slides.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-04 UTC."],[[["Google Sheets macros automate UI interactions, triggered by keyboard shortcuts or the Extensions menu."],["Macros are Apps Script functions stored in a bound script project, editable within the Apps Script editor."],["You can import existing Apps Script functions as macros or create new ones by editing the script manifest."],["Macros are limited to 10 keyboard shortcuts per sheet and cannot be used outside of bound Google Sheets scripts."],["When creating macros, prioritize lightweight, repetitive tasks and ensure unique keyboard shortcuts for optimal performance."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4