How to Create a Macro in Google Sheets: A Step-by-Step Guide

Google Sheets macros record spreadsheet actions and save them as Apps Script functions. They are useful for repetitive formatting or data-cleanup steps that you perform the same way each time.

  1. Open the spreadsheet.
  2. Choose Extensions > Macros > Record macro.
  3. Choose absolute or relative references based on how you want the recorded actions to behave.
  4. Perform the actions you want the macro to repeat.
  5. Choose Save, give the macro a clear name, and assign a shortcut if useful.
  6. Run the macro on test data before using it across an important sheet.

Absolute versus relative references

Absolute references target the same cells each time. Relative references replay actions based on the currently selected cell, which is more flexible but easier to misuse.

Macros create Apps Script

Recorded macros can be inspected and edited in Apps Script. Changes to the generated function can add logic that the recorder could not capture.

Permissions

Scripts can request authorization depending on what they do. Review permission prompts and code before authorizing scripts copied from other people.

Keep a test copy

A macro can overwrite values or formatting quickly. Duplicate an important sheet or maintain version history before running a new macro across a large range.

Triggers are separate

A recorded macro runs when invoked. Time-based or edit-based automation uses Apps Script triggers and should be configured deliberately.