Introduction to Using Apps Script With Google Sheets

Enhance Google Sheets With Apps Script PART I

James MacAdam
macadamScripts
3 min readJul 23, 2018

--

If you’ve ever wondered what Apps Script is, how in the world to use it, or have no clue what I’m even talking about, then you’re in the right place! When paired with Google Sheets, Apps Script has limitless potential. Apps Script paired with Google Sheets is the equivalent of VBA for Microsoft Excel. It is a JavaScript based platform and, along with all of your other Google Apps such as Sheets and Docs, is a cloud based service. This series of articles is dedicated to exploring some of the uses for Apps Script, specifically how it can make your spreadsheets more powerful than ever before.

Accessing Apps Script

Opening Apps Script from your Google Sheets Spreadsheet is as easy as clicking Tools > Script editor.

This creates a script template that is bound to your spreadsheet. Feel free to name your script in the top left corner whatever you would like!

Creating a Function

A function called myFunction is automatically created in the script template upon opening the script editor. In this example, we will add a command within this function that says hello to the spreadsheet user! First things first is getting the spreadsheet user interface and assigning it to a variable. Thankfully, Google’s API makes this easy using the SpreadsheetApp class. Lets go ahead and add the text var ui = SpreadsheetApp.getUi(); as part of myFunction. Now, adding a dialogue box that says hi to the user is as easy as ui.alert("Hello world!");

Now, go ahead and test your new function by clicking Run > Run function > myFunction. Head back over to your spreadsheet and hopefully you have a hello message!

Hello world!

If this is your first Apps Script function, then congratulations! There will hopefully be plenty more to come :) I hope that this has been a helpful introduction to Apps Script and encourage you to try this on your own! You may find it surprising how quick and easy, but yet very powerful, the scripting language is.

Please check out Part II of this series to see how to prompt the user for information and how to assign a script to a button within the spreadsheet!

Go to Part II

--

--

James MacAdam
macadamScripts

A Civil Engineer by day who is passionate about others, sharing ideas, building relationships, and learning new things. Columbus, OH. macadamscripts.com