Code to automate formatting in Google Sheets
Share on twitter
Share on linkedin
Share on facebook
Share on reddit
Share on telegram
Share on whatsapp
Share on email

Google Apps Script Tutorial for Beginners

In this Google Apps Script tutorial for beginners you’ll learn how to automate the formatting of a Google Sheets document. With just a couple lines of code, you can automate almost anything within Google’s many apps. You’re wondering what Google Apps Script is? The short answer to that question is: Google Apps Script is a scripting language based on JavaScript, that’s built in to Google apps. Have a look a this site for an in depth explanation. 

This tutorial also comes in video form, where basic programming concepts like variables, objects, etc. are explained. Go ahead and check it out.

Google Apps Script Tutorial - Where to get started

Look at most of the Google Apps and you’ll find your way to the script editor. In our tutorial we’re automating the formatting of a Google Sheets document. That’s why we access the script editor, where we will be writing our automation script, through Tools > Script editor in Google Sheets.

Access the script editor
In the menu choose Tools > Script editor

What you see now is the script editor with a placeholder function by the name myFunction. You can delete this function and start writing your own.

Script editor
The script editor with the placeholder function

Go ahead and copy the provided code to your script editor. You’ll see the orange comments that explain what is actually done with the provided code.

Before you leave the script editor be sure to save your automation script by clicking on the Save icon and giving it a name. In our tutorial we named our script Report Formatting.

The final code
The code needed for the automation to work

Running the automation script

To actually run our automation script so that it formats our report, we head back to our Google Sheet document.

Reload the document in your browser and after about 15 seconds our Custom Formatting appears in the menu list. That menu was created by the second function in our script we created.

Custom menu with item
Click the custom menu item to run the report

You will be asked to grant your script the rights to access your account. Confirm this. Then it might be necessary to click again on Custom Formatting > Format Report.

After about 5 seconds your report should look something like this.

Automatically formatted report
The automatically formatted report

Further Information

Do you have any questions concerning this tutorial or Google Apps Script in general? To go ahead and get in touch.

Subscribe to our Newsletter

Subscribe to our newsletter and be the first to know about our new blog posts and videos.

Share this post with your friends

Share on twitter
Share on linkedin
Share on facebook
Share on reddit
Share on telegram
Share on whatsapp
Share on email

Subscribe to our Weekly Newsletter

You’ll get tips, tricks and infos all about G Suite.