Even though there are hundreds of amazing things you can do using Google Sheets’ in-built functions and functionalities, there are specific scenarios when some tasks are impossible to execute by default, or you might need to take a longer route to achieve them, which might take a lot of your time.
Thankfully, with the Google Sheets App Script Editor, you can automate a lot of stuff or create a new Google Sheets script function that makes your job a walk in the park.
This Google Sheets tutorial will give you a comprehensive walkthrough of everything you need to know about the Google Sheets App Script editor. And to make things even easier, we will also show you some practical examples of using the Google Sheets App script editor.
Let’s get down to business, shall we?
What is Google Sheets Apps script?
Google Sheets Apps Script is a unique coding language carefully designed to allow users to create automation and functions for Google Apps, including popular apps like Google Forms, Google Sheets, Google Docs, Drive, Calendar, and even Maps.
While we will focus on using Apps Script for Google Sheets for this guide, most of what we will show you can also be applied to other Google apps.
For starters, Google Apps Script (GAS) uses the famous coding language, Javascript. It is written at the backend of Google Sheets (there is a clean and dedicated interface where you can write or copy/paste the code in the back end).
Since Google Sheets and other popular Google Apps are cloud-based, it also means that your Google Sheets Apps script is cloud-based. So when you create a code for a Google Sheets document and save it, you can access it from anywhere. In simple terms, Apps script doesn’t reside on your laptop; instead, it is stored on Google cloud servers.
What makes Google App script special?
Wondering what makes Google Apps script editor unique? Well, it’s because of its exciting use cases.
If you have always wanted to do more without spending much time on your computer, taking advantage of the Google Sheets App script editor wouldn’t be such a bad idea. But don’t take our word for it. Here are some reasons why Google App script editor is super useful.
Allows users to automate tasks
Assuming your job entails regularly downloading data from specific sources or databases and you have to combine and clean the data via Google Sheets, it will take you a series of steps and tons of hours to execute the task.
Of course, it may not be a big deal if these tasks only happen a few times. However, if this is something you have to do often, then automating the entire process will save you a great deal of time you can use for other things. And that’s where the Google Sheets Apps script editor comes in handy.
With the Google Sheets App script editor, you only need to create the code once. So whenever you need to execute the task, all you need to do is run the script code in Google sheets and watch GAS do all the hard job for you.
Extends the functionality of Google Sheets
If there is one thing we love about Google Sheets Apps script, it is the fact that it extends the functionality of Google Sheets.
Besides being a great tool for automating stuff and creating functions, we love how easy it is to utilize GAS to enhance Google Sheets functionality.
Even though Google Sheets has a plethora of functionality that works for everyone, we love that you can use Google Apps Script to code something suited to your needs.
And since you can always reuse the code now and then, it will make you more efficient and productive.
Can interact with Google apps
Being a common coding language that powers a lot of Google Apps, you can use Google Apps Script to communicate with other native Google Apps.
Let’s assume for a minute you have 10 Google Sheets documents somewhere in your Google Drive, you can easily use the Google Apps Script to combine all the scripts and delete the 10 Google Sheets documents from your drive.
This was made possible because the Apps script editor allows you to work with other native Google Apps.
Another practical way to use Google Apps script across multiple Google Apps is to use data housed within Google Sheets to schedule reminders in Google Calendar. Thanks to both apps supporting Google Apps Script, you can seamlessly do this.
Create new functions in Google Sheets
Already, Google Sheets offers seamless access to hundreds of amazing functions. And in most cases, these functions should get the job done.
However, sometimes you may want some extra functions to achieve specific results. In such a case, Google’s in-built functions may not suffice.
Good for you, Google Sheets Apps Script editor will help you create custom functions you can use to automate tasks. You can use these functions like you typically do when leveraging Google Sheets’ in-built functionalities.
If you have always wanted to make your job easier, creating new functions in Google Sheets using GAS wouldn’t be a bad idea.
Getting started with Google Sheets App Script editor
Google Sheets App Script editor is a tool available on Google Sheets that allows you to write scripts and then run them.
Each Google native app has a separate script editor. For instance, with Google Forms, a unique Script Editor allows you to write and execute codes within Google forms.
Where can you find Google Sheets App Script Editor?
Wondering where you can find Google Sheets App Script Editor? Read on as we show you how to find and navigate the Google Sheets App Script editor.
- To find Google Sheets App Script Editor, navigate to the Extension menu. From the options that appear, you should find Apps Script.
The image below shows you how to find the Google Sheets App Script editor:
Navigating Google Sheets Apps Script Editor
After selecting the Apps Script option, Google Sheets will automatically launch the Script Editor in a new Window. Here is what ours looks like
If you have a name for your project, you can enter it by clicking on the top part of the Script Editor where you have “Untitled project.”
Once you click on that option, it will open a dialog box that lets you enter the name of the project you’re working on. Keep in mind that it only takes a few seconds to implement the name change.
What’s unique about Google Sheets App Script editor is that it allows you to have multiple script files. Let’s assume you have three different things you’d like to automate in Google Sheets using Google Sheets App Script Editor, you can create three different scripts for the tasks you want to automate. What’s even more exciting is that you can have all three different scripts in the same project file.
If you look closely at the left plane of your Script Editor, you’ll find the default script file- Code.gs. This is the script file that allows you to write code. With this, you can have several scripts in the same script file or multiple script files, depending on what works for you.
If you click the three-dot icon next to the script file name, you’ll find three options: Rename, Make a copy, and Delete a copy of the script file.
Note: It’s important you have at least one script file in the project. Also, if you have just one, you won’t be able to delete it.
If you look closely at the right side of the script file, you’ll find a code window. This is where you’ll typically enter your code.
Understanding the script editor toolbar
Before you get started writing code in Google Sheets App Script editor, you need to familiarize yourself with the script editor toolbar. Here is what the Script Editor toolbar looks like:
Here is a brief overview of the various options on the Script Editor Toolbar.
- Redo/undo button: This button is important for making changes you have done in the script.
- Save button: This button is important for saving changes made to the script. It is pretty easy to use. All you have to do is click it to save any changes made.
- Run button: Use this button to run the script. In case you have multiple functions within your script, you can select the one you’d like to run and click the run button.
- Debug button: The debug button is designed to help users find any errors within their codes. Besides helping to spot errors in your code, the debug button also presents you with useful information. Any time you hit the debug button, you’ll find additional debugging options.
- A-Z button: Clicking this option will list all the functions you have in the script file. This button is super important, especially when you have multiple functions within your script file.
Google Sheets Script Editor
Now that you know how to navigate Google Sheets App Script editor, we will use this opportunity to look at some practical examples of using Google Sheets App Script Editor. For this guide, we will show you how to automatically generate charts with Google Sheets Apps Script.
Here is the sample data we will be using for our guide.
Step 1: Launch Apps Script
The first thing we need to do is launch Apps Script. And to do this, we need to head to the Extensions tab and select the option for “Apps Script.”
Step 2: Enter the code
After launching the Apps Script editor. Type the following code in the code window.
function SalesChart()
{ var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); var sheet = spreadsheet.getSheets()[0]; var SalesChart = sheet.newChart() .setChartType(Charts.ChartType.LINE) .addRange(sheet.getRange(‘A2:B10’)) .setPosition(5, 5, 0, 0) .build(); sheet.insertChart(SalesChart); }
Step 3: Click Run
With our code now entered in the code window. Click on Run.
If you did everything right. Your Script editor should look something like this:
Step 4: Check your Spreadsheet for updates
After entering your code and successfully running it, simply head back to your original spreadsheet and see if there are any changes.
After checking our spreadsheet, here is what we found:
From the image above, you can see we now have a line chart added to our spreadsheet. It means that our code works pretty fine.
Having saved the code, we can always use it in the future when creating a similar chart or working with similar data. This saves us the stress of doing everything from scratch.
That wasn’t too hard, was it?
Final thoughts
In this guide, we gave you a detailed walkthrough on everything you need to know about Google Sheets App Script editor. We started by providing a basic understanding of what Google Sheets App Script editor is.
Having established that, we reviewed why the Google Sheets App Script editor is unique. Not just that we also showed you how you could navigate the Google Sheets App Script editor with no fuss.
Finally, we reviewed some practical examples of using Google Sheets Apps Script editor. In our example, we showed you how to automatically generate charts using Google Sheets App Script Editor.
While Google Sheets App Script Editor might look intimidating, especially if you’re using it for the first time, we are sure that after reading today’s guide, you’ll agree that Google Sheets Apps Script is pretty easy to use. And the best part is that it makes your job easy.
For people whose job entails executing repetitive tasks on Google Sheets, using Apps Script will save you a lot of time and stress.
We sincerely hope you found this Google Sheets tutorial worth it.
In case you need more clarification about something you don’t understand, feel free to leave a comment, and we will be more than happy to respond.
Other Google Sheets Resources You May Find Useful
- How to Create Data Entry Form in Google Sheets
- How to Make a Bell Curve in Google Sheets
- How to Create a Combo Chart in Google Sheets
- How to Create a Timeline Chart in Google Sheets
- How to Create Dynamic Chart Range in Google Sheets
- How to Create an Area Chart in Google Sheets
- How to Create Pivot Table in Google Sheets
- Google Sheets Conditional Formatting Custom Formula (with Examples)
- How To Create Drop-Down List In Google Sheets (With Examples)