Google Sheets Macro Button: Create and Assign One

VBA & macros · Updated November 21, 2026

To make a Google Sheets macro button, insert a drawing or an image over the cells, open its three-dot menu, choose Assign script, and enter the name of a function in the spreadsheet’s Apps Script project. You can use a function created by recording a macro or write one yourself; clicking the object runs that function.

What a Google Sheets macro button is

A macro button is a clickable drawing or floating image that runs a Google Apps Script function in the spreadsheet. It looks like a button, but it is not a special form control: the shape or image acts as the clickable surface, and the assigned script does the work. You can label a drawing “Format report,” “Clear entry form,” or “Add today’s date” so its purpose is clear to collaborators.

Google Sheets macros are also Apps Script functions. When you record a macro, Sheets translates the actions into script code, saves that code with the spreadsheet, and makes the macro available from the Extensions > Macros menu. A button gives people another way to run a function without opening that menu. It does not automatically create a macro or script; it simply calls a function that already exists.

Create the clickable object

First, open the spreadsheet in Google Sheets in a web browser. Choose one of these object types:

  • Drawing: Select Insert > Drawing, create a shape, add text if you want a visible label, and choose Save and close. A drawing is usually the clearest choice for a simple, labeled button.
  • Image over cells: Select Insert > Image > Image over cells and choose an image. This can suit a branded icon or custom graphic. An image placed in a cell is different and cannot be used as the clickable script button.

The drawing or floating image sits above the grid, so you can move and resize it without changing cell contents. Position it where people will look for the action, and leave enough room that it does not cover important data. For a button that should stay visually associated with a table, place it near the relevant columns and add a label that describes the result rather than a vague word such as “Go.”

Record a macro before assigning the button

If the task is a repeatable sequence of ordinary spreadsheet actions, recording it may be the easiest way to create the function. Choose Extensions > Macros > Record macro. In the recording controls, choose whether to use absolute or relative references, perform the actions, and select Save. Give the macro a name; Sheets then adds the generated function to the spreadsheet’s bound Apps Script project.

Absolute references repeat actions on the same cells. Relative references apply actions in relation to the cell or range selected when the macro runs. For example, formatting a fixed title cell suits an absolute reference. Applying the same number format to whichever range a person selects is a relative-style task. Choose deliberately: a macro that targets the wrong range can alter data or formatting unexpectedly.

Recording is useful for repetitive formatting, navigation, and simple editing, but it is not a way to capture every possible workflow. Review the resulting behavior before sharing it, particularly if the task depends on a selected range or could overwrite existing entries. To inspect or edit the generated code, open Extensions > Apps Script. The function name shown in the script is the name you will assign to the button.

Assign a function to the button

Once the drawing or image and the function are ready, select the object in the sheet and open its three-dot menu. Choose Assign script. Type the function name exactly as it appears in Apps Script, then select OK. Enter the name alone, without parentheses. For example, if the function is named markComplete, enter markComplete, not markComplete().

A simple custom function can show what the connection means. In the spreadsheet’s bound Apps Script project, this function writes “Done” into the selected cell:

function markComplete() {
  const sheet = SpreadsheetApp.getActiveSheet();
  const range = sheet.getActiveRange();
  range.setValue('Done');
}

With that function assigned, clicking the drawing runs it on the active sheet and active range. That example is intentionally small: a production script should account for the intended sheet and range, and should avoid replacing important data without warning. If you want a button to act on a fixed range rather than the current selection, write the function to target that range explicitly and check that the spreadsheet structure will remain consistent.

If Assign script is missing, check that you selected a drawing or an image over cells rather than an image in a cell. Also make sure the script is in the spreadsheet’s Apps Script project and that the spelling and capitalization of the function name match.

What happens when someone clicks it

In a desktop browser, a click on the assigned drawing or image invokes its named function. The function runs in the context of the spreadsheet’s Apps Script project, subject to the permissions and access that apply to the user and the script. On a first run, Google may ask a user to authorize the script, depending on what it does and whether that user has already granted the required permissions. A function that only changes the current spreadsheet may need different access from one that also uses other Google services.

People who use the button need suitable access to the spreadsheet, and the script may require each user to authorize it. Do not assume that sharing the sheet means every user can run every script without a prompt. Test with an account that represents the intended audience, and explain what the button changes before asking colleagues to click it. If the function relies on a particular tab, selected range, or data layout, state that near the button.

Buttons assigned this way are intended for use in Sheets on the web. Do not promise that the same click-to-run interaction will work in the Sheets mobile apps. If mobile users need the operation, provide a suitable alternative workflow and verify it for the devices and permissions they actually use.

Button, macro menu, or keyboard shortcut?

A button is useful when the action should be visible and easy to find, especially for occasional users who may not know where macros are listed. A macro in Extensions > Macros is better when you do not need a prominent on-sheet control. A keyboard shortcut can be quicker for frequent users, but it is less discoverable and may be inconvenient on some keyboards.

When saving a recorded macro, Sheets can offer a shortcut. Macro shortcuts use a numbered combination with Ctrl, Alt, and Shift on Windows or ChromeOS; on Mac, the corresponding combination uses Control, Option, and Shift. The available number is part of the shortcut, and the user must know the combination. For an occasional workflow shared with a broad group, a clearly labeled drawing is often easier to understand than expecting everyone to remember a shortcut.

You can have several drawings on one sheet, each assigned to a different function. Keep the set small and purposeful: a cluster of unlabeled controls can be harder to use than the menu it replaces. For tasks with multiple inputs or choices, a button alone may also be too limited; a custom Apps Script interface or a simpler data-entry design could be more suitable.

Good uses and practical limits

Macro buttons work best for repeatable, predictable actions within a spreadsheet. Examples include applying a standard format to a report, inserting a prepared value into a defined location, or running a routine cleanup on a known range. They are less appropriate for actions where the user must make several decisions, where the sheet layout changes often, or where a mistake could silently delete or replace valuable information.

Recorded macros reproduce supported actions as code; they are not a general-purpose recording of a person’s intent. A sequence that works today may behave differently if rows, columns, tabs, or the active selection change. Inspect the script and test it on a copy or sample data before relying on it. If you edit the function later, the button can keep calling it as long as the function name stays the same and remains available in the project.

Also distinguish a button from a spreadsheet formula. A formula recalculates based on cell values; a script runs when invoked and can make changes or interact with Google services according to its permissions. If a result can be expressed with a normal formula, that is often easier for others to audit and maintain. Use a script when the desired operation is an action that formulas do not provide conveniently.

Common problems and fixes

  • The button does nothing or reports that a function cannot be found: Confirm the assigned name matches the Apps Script function exactly, including capitalization, and has no parentheses. Confirm the function is saved in the spreadsheet’s script project.
  • There is no Assign script option: Select a drawing or an image over cells. An image inserted in a cell is not the same kind of object for script assignment.
  • The function runs on the wrong cells: Check whether the script uses the active sheet or active selection. A recorded macro may also use absolute references when relative references were intended. Adjust the function or give users clear instructions about what to select.
  • A permission screen appears: This can be expected when a user first runs a script or when the script requests new access. Read the prompt and verify that the script is trusted before authorizing it; do not tell users to approve an unfamiliar script automatically.
  • The button is difficult to click or covers data: Resize or move the floating object, use a stronger label, and test the sheet at the zoom level and screen size people are likely to use.

When troubleshooting, run the function from the Apps Script editor as well as from the drawing, if appropriate. This can help distinguish a problem in the function from a problem with the object’s assignment. For any function that changes many cells, test with disposable data first. Script-driven changes may not be straightforward to reverse with the normal undo command, so keep a copy before experimenting.

Safety, sharing, and maintenance

A button makes an action easy to launch, so make its purpose and effects obvious. Avoid labels such as “Run” when the script deletes rows, clears a range, or updates a shared record. For destructive or wide-ranging operations, consider adding confirmation logic, checking the target sheet and range in the script, and retaining a recoverable copy of important data. Test changes after edits to the script, the sheet layout, or sharing settings.

Keep the script understandable for whoever maintains the spreadsheet. Use descriptive function names, add brief comments for non-obvious behavior, and document any assumptions about tab names or selected cells. If you copy a spreadsheet, check the copied script and button assignment rather than assuming the workflow has been set up exactly as intended. Access to the spreadsheet and authorization to run a script are related but distinct considerations.

How this differs from an Excel macro button

Google Sheets uses Apps Script for recorded macros and assigned drawing or image buttons. Excel has its own macro system, commonly using VBA, and its button setup and menus differ. Instructions for inserting an Excel Form Control button or assigning a VBA macro do not apply to Google Sheets. Likewise, a Sheets Apps Script function is not automatically interchangeable with VBA code. If a team uses both products, plan for separate implementations and test each in its own application.

Frequently Asked Questions

Can I assign a macro I recorded to a button?
Yes. A recorded macro creates a function in the spreadsheet’s Apps Script project. Assign that function’s exact name to a drawing or an image over cells through its three-dot menu and Assign script.

Can I use a cell as the macro button?
Not directly through the drawing-and-image assignment feature. Use a drawing or an image over cells as the clickable object. A cell can still hold information that a script reads, but it is not itself the assigned button.

Do I type parentheses after the function name?
No. Enter only the function name, such as markComplete. Do not include parentheses, arguments, or extra spaces.

Can I use the button in the Google Sheets mobile app?
Do not rely on the assigned drawing or image as a mobile control. This click-to-run method is intended for Sheets in a web browser, so provide another workflow if mobile use is essential.

Why does Google ask me to authorize the script?
Scripts may need permission to access the spreadsheet or other Google services. A user may see an authorization prompt on first use or after the script’s requested access changes. Review the script and prompt before granting access.

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.