View Macros in Google Sheets: Find and Read the Code

VBA & macros · Updated November 3, 2026

View Macros in Google Sheets: Find and Read the Code

To view a macro in Google Sheets, open the spreadsheet in a web browser and choose Extensions > Apps Script to inspect its script code. To see which macros are available to run, use Extensions > Macros; choose Manage macros if you want to review the macro list and its available settings.

What a Google Sheets macro contains

A Google Sheets macro is a recorded set of spreadsheet actions implemented as a function in Google Apps Script. When you record actions such as formatting cells or entering a formula, Sheets creates script code for the operations it can capture. The code is associated with the spreadsheet, rather than being a VBA macro embedded in an Excel workbook.

This distinction matters because there are two different things someone might mean by viewing a macro. The macro list shows names of macros you can run. The Apps Script project shows the instructions that make a macro work. Seeing a macro name does not, by itself, reveal what its code does.

Recorded macros are useful for repeating routine work, but the recording is not a video or a plain-language checklist. It is script code. A recording might produce a function that selects a range and applies formatting through spreadsheet services. If a recorded action is not supported by the macro recorder, it may not appear as an equivalent instruction in the generated code.

Find the macro list and its settings

Open the spreadsheet in Google Sheets on the web, then choose Extensions > Macros. That menu shows macros available in the current spreadsheet and lets you run one by selecting its name. Choose Manage macros to review registered macros and settings such as their names or keyboard shortcuts. The exact controls shown can depend on the Sheets interface and your access to the file.

This menu is the quickest way to confirm that a macro is registered, but it is not the best place to understand the actual instructions. For source code, use the Apps Script editor. If a function exists in the script project but is not listed in the Macros menu, it may need to be registered through the macro management controls before it can be launched as a Sheets macro.

To make a script function available as a macro, Sheets provides an import option under Extensions > Macros in supported interfaces. Importing a function registers it for the spreadsheet’s macro menu; it does not change the function into a different programming language. If you cannot find an import or management control, check that you have opened the intended spreadsheet and have editing access.

Open and inspect the Apps Script source

  1. Open the spreadsheet that contains the macro in a desktop web browser.
  2. Choose Extensions > Apps Script. This opens the Apps Script project associated with the spreadsheet, if you have permission to access it.
  3. In the editor, open the relevant script file, often named Code.gs. Look for functions corresponding to the macro names shown in Sheets.
  4. Read the function and any helper functions it calls. A macro may call another function, so checking only the first few lines might not show everything it does.

A macro function commonly has a name such as macro1 or a descriptive name chosen by an editor. The function name is not always identical to the label visible in the Sheets menu: registered macros can have display names. If the project has several files or functions, use the editor’s search to look for the function name or a distinctive spreadsheet operation.

Apps Script changes are separate from ordinary cell edits. If you only want to inspect the code, avoid editing or running it. If you do make changes, confirm that they are saved in the script editor and then return to the spreadsheet to check the macro registration and behavior. A script can include helper functions that are not themselves listed as macros.

How to read recorded macro code

Generated Apps Script often uses the SpreadsheetApp service to interact with the open spreadsheet. It may identify a sheet, select a range, set a value, change number formats, or apply formatting. Those calls are the script’s instructions; the order matters. For instance, a function that first selects a range and then sets its background color is applying that color to the selected cells.

When inspecting code, trace what spreadsheet and range the script targets. Some scripts act on the active sheet or active selection, so their result can depend on which tab or cells are active when the macro runs. Other code names a particular sheet or range explicitly. A macro that uses a fixed range may not automatically include new rows added later.

  • Check the target: identify the sheet and range being changed. Look for calls that retrieve the active spreadsheet, active sheet, or a specifically named tab.
  • Check the actions: note whether the code writes values, changes formatting, clears cells, inserts rows, or performs another operation.
  • Check the scope: follow any helper functions and inspect loops or conditions that could affect additional cells.
  • Check external services: look for code that uses services beyond spreadsheet editing, such as email or Drive access, before authorizing or running it.

Recorded code can be more literal than a human-written script: it may repeat selections or formatting instructions that could be simplified. Do not assume that code is harmless just because it came from a macro recorder. If someone has edited the project, the current script may do more than the original recording did.

Access, permissions, and missing macros

Access to the spreadsheet and access to its associated script are related. A person with view-only access may be able to see the sheet but not inspect or edit its bound script. Ask the owner for the appropriate access if you need to review the code; do not make a copy or request broader permissions unless that is necessary for your task. Editors can typically access the bound project, but organizational policies can also affect Apps Script access.

If a macro is missing from the menu, first confirm that you opened the correct spreadsheet. Then check Extensions > Macros and the Apps Script project. A function may have been renamed, deleted, or never imported into the macro list. A macro recorded in a different spreadsheet will not automatically appear in this one, because each spreadsheet has its own associated project.

Other common causes include insufficient editing access, a script project that has not finished loading, or a function that no longer works as registered. If the macro appears but fails when run, read the error message and check whether the script needs authorization. The first run of a script may prompt the user to review and grant requested permissions. A failure can also result from a renamed sheet, changed ranges, or an assumption about the active tab that is no longer true.

Run a macro only after checking what it does

Viewing a macro does not execute it. Running one from Extensions > Macros does. A script may change or clear spreadsheet data, and some scripts may request permission to use other Google services. Before running a macro from another person or an unfamiliar file, inspect the code and consider whether its requested access matches its apparent purpose.

For a consequential workbook, make a copy or otherwise preserve the original data before trying an unfamiliar macro. Google Sheets does not provide the same dependable undo experience for every script action as it does for ordinary edits; do not rely on repeated Ctrl+Z to reverse a macro. If a script requests access that seems unrelated to the task, cancel rather than approving it until the owner can explain why that access is needed.

Authorization is not proof that a script is safe. It means the user has granted the listed access. Read the requested permissions, consider who supplied the file, and avoid running code you do not understand. For organization-managed accounts, an administrator may restrict Apps Script or certain services, so an otherwise valid macro may still be blocked.

Google Sheets macros compared with Excel macros

Google Sheets macros use Google Apps Script, a JavaScript-based scripting environment. Excel macros commonly use Visual Basic for Applications (VBA). The languages, editors, object models, file formats, and permissions are different. A VBA macro copied from an Excel workbook will not run as a Google Sheets macro just because both are called macros.

In Excel for Microsoft 365 on Windows, people commonly inspect VBA through the Visual Basic Editor or the Developer tools, and macro-enabled workbooks use formats such as .xlsm. In Sheets, use Extensions > Apps Script for the associated script and the Sheets macro menu for registered functions. Moving an automated task between the products generally means translating its logic and checking how each application handles ranges, permissions, and files; it is not a direct code conversion.

Another practical difference is where automation runs. A Sheets macro is tied to a Google spreadsheet and uses Google’s services, while an Excel VBA macro runs in the Excel environment and may depend on Windows-specific features. If you are following instructions written for Excel, do not expect to find a VBA editor or VBA code inside Google Sheets.

Alternatives when you only need to understand a process

If you do not have access to the source, ask the spreadsheet owner what the macro is intended to change and whether they can provide an explanation. You can also inspect the visible sheet before and after a run only if you are authorized and working with a safe copy. That can help identify the outcome, but it does not replace reviewing the code: a macro can have effects that are not obvious from the cells currently on screen.

For a simple repeated operation, built-in Sheets features may be easier to understand than a script. Sorting, filters, conditional formatting, and formulas can handle many routine spreadsheet tasks without requiring a macro. For more involved automation, Apps Script offers more flexibility, but it also makes it important to review permissions, test on a copy, and maintain the code when the sheet’s layout changes.

Frequently Asked Questions

Can I view a macro without running it?
Yes. Open Extensions > Apps Script to inspect the source without launching the macro. Opening the editor is different from selecting the macro to run.

Where do I find macros in Google Sheets?
In the web version, open Extensions > Macros. That menu lists registered macros for the spreadsheet and provides access to available macro management controls.

Why can I see a spreadsheet but not its macro code?
Your account may have view-only access or lack permission to open the associated Apps Script project. Ask the spreadsheet owner for appropriate access if reviewing the source is part of your work.

Can Google Sheets open or run an Excel VBA macro?
No. Sheets macros use Apps Script, not VBA. The automation needs to be rewritten for Apps Script or kept in an Excel environment that supports the VBA project.

Does viewing a macro change the spreadsheet?
No. Opening the macro list or Apps Script editor to read the source does not run the function. Changes occur when the code is edited or executed, so avoid selecting a macro to run while you are only investigating it.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.