This guide walks you through creating “buttons” in Google Sheet’s UI to trigger Google Apps Script function calls.
Google Apps Script is very handy for automating common tasks in Google Sheets, Google Docs, Google Drive, and so on. Within Google Sheets, these scripts can be triggered in response to events (e.g. time of day), via a menu in the UI, or through the script editor itself.
These forms of triggering, however, may not be intuitive for all users. A more intuitive way to get users to trigger the right Google Apps Script functions within Google Sheets is to provide buttons that they can click. Unfortunately buttons are not a native feature of Google Sheets; but we can workaround this with images and triggers.
Create a button image using Google Drawings
You can skip this step if you already have an image or prefer to use another image editor.
Log in to Google Drive
Create a new Google Drawings file by clicking on New > More > Google Drawings
Create a simple drawing to represent your button
Resize the canvas to fit the dimensions of the button. Do this by dragging the handle at the bottom right corner of the canvas.
Download the image as a
Insert the button into Google Sheets
Go to the sheet where you wish the button to appear.
Click on a cell closest to where you want the button to appear.
Select Insert > Image
Select the file you created and upload it
You should now see the button on your sheet. Use your mouse to position the image exactly where you want it.
Set a script to trigger when the button image is clicked
Click on the image and then the three dots. Select Assign script…
Enter the name of the function, without any parentheses, that you wish to trigger whenever the button is clicked.In the below example we are referring to a function called
Now you have a button (or rather, an image that mimics a button) in Google Sheets that will trigger a Google Apps Script function whenever it is clicked.