How to Make a Google Sheets Button [Ultimate Guide]

7 Minutes

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. 

google sheets add button

The Drawing canvas will appear. 

add button to google sheets

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.

create button in google sheets

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:

how to make a button in google sheets

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

insert button google sheets

The button will now appear as an image in the Google Sheets. 

How to Assign Google Apps Script to Button

We will show you a quick example below, but click here to read our complete tutorial and FAQs for using a Google sheets button to run a script.

For this example, we will use the Google Apps script below:

var server = 'server_url';

var port = port_number;

var dbName = 'database_name';

var username = 'username';

var password = 'password';

var url = 'jdbc:mysql://'+server+':'+port+'/'+dbName;


function readData() {

 var conn = Jdbc.getConnection(url, username, password);

 var stmt = conn.createStatement();

 var results = stmt.executeQuery('SELECT * FROM table_title’);

 var metaData=results.getMetaData();

 var numCols = metaData.getColumnCount();

 var spreadsheet = SpreadsheetApp.getActive();

 var sheet = spreadsheet.getSheetByName('Sheet1');


 var arr=[];


 for (var col = 0; col < numCols; col++) {

   arr.push(metaData.getColumnName(col + 1));





while ( {


 for (var col = 0; col < numCols; col++) {

   arr.push(results.getString(col + 1));







sheet.autoResizeColumns(1, numCols+1);

Step 1: Click the three dots on the upper-right corner of the button. A drop-down list will appear. Click Assign script.

how to add a button in google sheets

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.

assign script to button

You are now done! 

You can test it by clicking the image. The notification Running script will appear. 

Running script notification

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).

unverified Google Apps Script Function

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.

Button output


Your button works. You can now use this to improve the dashboard you are creating in Google Sheets.  

Related Articles

-How to Create a Google Sheets Dashboard

-Automatically Send Emails from Google Sheets

Tired of constantly monitoring your spreadsheets? Scale operations with Lido automations and free up time to focus on what really matters.