Contact

Google Sheets · Automation bounded introductory track · Intermediate

Record and maintain a Google Sheets macro

Record formatting-only absolute and relative macros, test changed selections, and maintain the bound script safely.

Documentation-reviewed author candidate; no native application execution. · Editorial standards

Quick answer

Choose Extensions > Macros > Record macro, select absolute or relative references, perform one small formatting action, and save it with a descriptive name. Replay the macro from a different selected cell to prove which reference mode you recorded. Keep the first exercise formatting-only so a wrong target cannot overwrite data.

Prepare two obvious targets

Use desktop Google Sheets in a private practice workbook. Macro recording requires a computer; the mobile help does not provide equivalent creation controls. You should own the file and understand that recording creates a bound Apps Script function, not just a saved visual preference.

Name a tab MacroLab. Enter Header A in A1, Header D in D1, and Control G in G1. Leave all three cells unbolded. Put a small data row under them if you want a clearer visual check, but do not include it in the recording. The intended change is only bold text on one header cell. A1, D1 and G1 must keep their original text throughout.

Write down the initial state: all three headings normal weight. This is your recovery checkpoint. Do not practice on a production sheet where automated formatting could hide warnings or disturb a report.

Record the absolute version

  1. Select A1 before starting the recorder.
  2. Choose Extensions > Macros > Record macro.
  3. Select Use absolute references in the recording controls.
  4. Apply bold to A1 using the toolbar or Format menu. Do not type replacement text, change tabs or make unrelated edits during recording.
  5. Click Save, name the macro Bold A1 absolute, and save it. A keyboard shortcut is optional; leave it unset for this first comparison.

Recording itself applies the formatting, so A1 should now be bold. Manually return A1 to normal weight before testing replay. Select D1 and run Extensions > Macros > Bold A1 absolute. The expected result is that A1 becomes bold and D1 remains normal. The selected cell changed, but the recorded absolute target did not.

If an authorization prompt appears, inspect the script and requested access before deciding whether to continue. For this self-authored formatting exercise, unrelated services such as email or external websites are not needed. Stop at an unexpected scope or security warning rather than clicking through merely to reach the next step.

Record the relative version

Return A1 to normal weight and select A1 again. Start a second recording, this time choosing Use relative references. Apply bold to A1, save as Bold selected relative, and stop recording. Reset A1 to normal once more.

Now select D1 and run Bold selected relative. D1 should become bold while A1 remains normal. Reset D1, select G1, and repeat: G1 should become bold while A1 and D1 remain normal. The changed selection is the test input; the text values are the unchanged control.

This recorder setting is not the same thing as dollar signs in spreadsheet formulas. A relative macro changes its action location relative to your selection. It does not convert a formula’s reference style or make a recorded workflow understand the meaning of your data.

Inspect the generated operation

Open Extensions > Macros > Manage macros. Find the exact macro and choose its More > Edit macro action to inspect the bound Apps Script. Google documents generated macro functions in a file named macros.gs. Inspect which range is addressed and which formatting operation is applied. Do not paste in a replacement script from an unreviewed website.

For this tutorial the behavior should remain a small spreadsheet-formatting operation. If you recorded typing, extra selections or a sheet change by accident, make a clean new recording rather than trying to reason about a long sequence of unintended actions. Preserve the first working version until the replacement passes the same A1/D1/G1 tests.

A script annotation such as @OnlyCurrentDoc can limit relevant authorization to the current document. It is not a substitute for reviewing the actual generated code. Do not add broader services, triggers, deployments or credentials to a formatting macro.

Maintain names and test repeatability

In Manage macros, rename confusing entries so the location policy is obvious, and click Update to save the configuration. If you later assign a shortcut, make it unique. The menu is a clearer test route when troubleshooting because it shows exactly which macro you chose.

Run the relative macro twice on G1. The desired final state remains bold; this exercise is intended to apply a format, not alternate business data between two states. If your recording instead toggles unexpectedly, inspect the generated operation and re-record a clear formatting assignment. Verify that all three text labels remain untouched.

Reset the three headings manually to normal weight when finished. Removing a macro does not undo formatting it already applied. Use Manage macros to remove only the disposable entries after checking the names, or retain them in the private practice file with a note explaining the test.

Troubleshooting and persistence

If the wrong cell changes, first confirm the selected macro name and recorded reference mode. If nothing happens, verify whether the target was already bold and inspect execution errors rather than assuming failure. If permissions are blocked by policy, stop and consult the administrator; recording a new name is not a bypass.

After Sheets saves, close and reopen the workbook and check that the intended macro still appears. A downloaded Excel file is not proof that its bound Apps Script macro will run in Excel. Keep the native Sheets file for this workflow.

No macro was recorded, authorized or executed during authoring.

Official references

References: Google’s macro recorder help, macro development and editing guide, and authorization scope guidance.