How to Add a Script to Google Sheets (Easiest Way in 2023!)

Adding a script to Google Sheets is easy! In just a few clicks you can add any script. Simply follow the steps below.

Add Script to Google Sheets

1. Open your Google Sheets workbook

For this example, we will add a script to Google Sheets that allows you to automatically send emails. 

add script to google sheets

2. Go to Extensions > Apps Script

Apps Script is a tool created by Google that allows you to run code scripts in your spreadsheet . 

There are several things we can use Apps Script for such as creating new functions, adding custom menus or sidebars, building add-ons, integrating with other Google Workspace applications and a lot more. 

how to add script to google sheets

3. In the Script Editor, input your script

Our script for sending emails automatically would be:

function sendEmail() {

var ss = SpreadsheetApp.getActiveSpreadsheet()

var sheet1=ss.getSheetByName('Sheet1');

var sheet2=ss.getSheetByName('Sheet2');

var subject = sheet2.getRange(2,1).getValue();

var n=sheet1.getLastRow();

for (var i = 2; i < n+1 ; i++ ) {

var emailAddress = sheet1.getRange(i,2).getValue();

var name=sheet1.getRange(i,1).getValue();

var ServiceAcquired=sheet1.getRange(i,3).getValue();

var message = sheet2.getRange(2,2).getValue();


MailApp.sendEmail(emailAddress, subject, message);



This is how it would look like in our editor.

google sheets add script

Refer to our Send Emails Automatically In Google Sheets article for more information on how to edit this script and what it does.

4. Rename your Project and Save your Script.

You can name it however you want to and simply press the save icon to save it.

Script for sending Email in Google Sheets

5. Run Code and Grant Permissions

The run code button will be beside the save icon. This will then prompt you to grant access to your code since it is a custom and unknown script

Running Scripts in Google Sheets

To set up permissions: Click Review Permissions. Go to Advanced Settings -> Click “Go to Send Email” and allow the permissions. This will run your program and email your recipients.

Allowing Script to run

6. Now you will be able to run your script

Our script example will automatically send emails using Gmail based on our worksheet contents. We can see below how multiple emails were easily sent after running our script.

Sending Emails with Apps Script on Google Sheets

Using Apps Script, we can also use other scripts based on what we want to achieve with our data. Here are other Lido articles that will help you get started in automating with Google Sheets:

-Use Button to Run Script

-Connect MongoDB to Google Sheets With Script

Lido is a new spreadsheet built for automation. Trigger emails, slack messages, and more directly from a spreadsheet.