How to Make a Google Sheets Button [Ultimate Guide]
A Google Sheets button is an essential tool in your Google Sheets arsenal. Buttons in Google Sheets can be an awesome way to easily trigger custom scripts, greatly increasing speed and functionality.
We have already written some tutorials about adding and running custom scripts to Google Sheets in order to expand its functionality. One of these is about importing data from MySQL database to Google Sheets. The custom scripts can either run automatically or you can run them by typing the function name into the cell as an equation. Can we improve on this by, let's say, adding a button that we can click to run the script? Of course! We will learn how to do that in this tutorial. Are you ready?
How to Add a Button in Google Sheets
Step 1: Click Insert on the main menu, then click Drawing in the drop-down list.
The Drawing canvas will appear.
Step 2: Click the Shape option. Several types of shapes will appear. After selecting the shape, draw it across the canvas to whatever size you want it to be.
Afterwards, click the Text box option to add a textbox over the button. Drag it to a certain size within the shape and then type the label that you want.
The button can look like as follows:
Ultimately, the design of the button will be your choice, and given the range of shapes available in Google Sheets, you will not have a hard time finding the one that fits your idea.
Step 3: If you are satisfied with your button, click Save and Close
The button will now appear as an image in the Google Sheets.
Step 1: Click the three dots on the upper-right corner of the button. A drop-down list will appear. Click Assign script.
Step 2: A pop-up box will appear, asking you what script you want to assign to the image. Type the function name, then click Ok.
You are now done!
You can test it by clicking the image. The notification Running script will appear.
When you run the script for the first time in that spreadsheet, you will receive a prompt that the script attached to this document needs your permission to run. Click Continue.
The add-ons created by third-party users for Google apps undergo a validation process by Google to ensure that the add-ons are not intended for malicious purposes by its creators. Click Advanced, then click Go to *name of your script* (unsafe).
The usual procedure for permission requests will appear. Once done, the script will run. You can click the button again to make sure that the script runs as intended.
Your button works. You can now use this to improve the dashboard you are creating in Google Sheets.