How to Automate Google Sheets With Macros

Google Sheets lets you automate repetitive tasks with macros, and you can then bind them to keyboard shortcuts to execute them quickly. They work using Google Apps Script to capture your actions for later use.
What are Macros?
A macro or macroinstruction is a specific sequence of actions that let you automate a series of steps to increase productivity. They work by recording your actions and saving them into a file that’s bound to the spreadsheet in which they were recorded.
When you record a macro in Google Sheets, it automatically creates an Apps Script with all the code to replicate your actions for you. This means you can create complex macros without knowing how to write code. The next time you run it, Sheets will do everything you did when you recorded the macro. Essentially, you’re teaching Google Sheets how to manipulate a document to your liking with a single command.
Macros are a powerful feature that can do basically anything Sheets is capable of doing. Here are just a few examples of its functionality:
- Apply formatting and styles.
- Create completely new spreadsheets.
- Use any Google Sheets function, toolbar, menu, or feature.
The sky is the limit.
How to Record a Macro in Google Sheets
Fire up a Google Sheet and click Tools > Macros > Record Macro.

After you’ve captured all the actions for this macro, click “Save.”

Enter a name for your macro. Google also lets you create shortcuts for up to ten macros. If you want to bind a macro to a keyboard shortcut, enter a number from 0-9 in the space provided. When you finish, click “Save.”

RELATED: How to Insert a Google Sheets Spreadsheet into Google Docs
If you need to tweak your macro’s name or shortcut, you can edit a macro by clicking Tools > Macros > Manage Macros.

The next time you press the shortcut associated with the macro, it will run without having to open the macro menu from the toolbar.
How to Run a Macro in Google Sheets
If your macro is an absolute reference, you can run the macro by pressing the keyboard shortcut or go to Tools > Macros > Your Macro and then click the appropriate option.

All macros save to the same file, so if you have a couple of macros saved, you may have to sift through them. The function’s name is the same one you gave it when you created it.
Highlight the macro(s) you want to copy, then press Ctrl + C. Be sure to copy everything up to and including the closing semi-colon.

Now, open the other spreadsheet you’ll be importing the macro to and click Tools > Macros > Record Macro.

Click “Save” again.

Open Google Apps Script by clicking Tools > Script Editor, and then open the macros.gs file from the left pane. Delete the existing function and then press Ctrl + V to paste in the macro from your other Sheet.

Press Ctrl + S to save the script, close the tab, and return to your spreadsheet.
Your spreadsheet reads the macros.gs file and looks for changes made to it. If a new function is detected, you can use the Import feature to add a macro from another sheet.
Next, click Tools > Macros > Import.

Unfortunately, you will have to bind the macro manually to a keyboard shortcut again. Just follow the instruction previously mentioned, and you’ll be all set to use this macro across multiple sheets.

Comments are closed.