Creating your first Apps Script

First, go ahead and create a new Google Sheet. I created one called First Apps Script.

Pro tip: You can use the link to create a new sheet.

Screenshot of a Google Sheets spreadsheet.

Then, select Extensions > Apps Script.

This will open a new project in the Apps Script editor.

Screenshot of the Google Apps Script editor.

Give your project a name by clicking on "Untitled project".

There are three main sections in the Apps Script project UI.

  • The files in your project are displayed in a sidebar on the left.

  • If you select a file, its contents will be displayed in a code editor that occupies most of the screen.

  • There is a toolbar above the code editor.

Screenshot of the Google Apps Script editor.

You'll notice the following code in the editor:

function myFunction() {

Screenshot of the Google Apps Script editor.

A function is a piece of code that has a name. You can run (or execute) this piece of code elsewhere in your program by using its name. You can also run a function by selecting its name in the dropdown menu in the toolbar and clicking the Run button.

Right now, running this function will not do anything. This is because the function myFunction is empty. There is nothing for it to do when you run it. Let's change that.

Add the following code between the two curly braces { and }.

Screenshot of the Google Apps Script editor.

A log is like a diary for your code. It is used to record what your code did. We're using it to record the number 101. That's not super useful but that's OK. You'll eventually learn how to use it.

The editor should have the following code in it.

function myFunction() {

Now save your script and then try running myFunction again by clicking the Run button.

Your script will run and will record 101.0 to the execution log. You'll also see the time at which the log entry was made. Click [X] to close the window.

A screenshot of the Google Apps Script editor with 101.0 written to the execution log.

You can open or close the execution log by clicking on the Execution log button.

Stay up to date

Follow me via email to receive actionable tips and other exclusive content. I'll also send you notifications when I publish new content.
By signing up you agree to the Privacy Policy & Terms.

Have feedback for me?

I'd appreciate any feedback you can give me regarding this post.

Was it useful? Are there any errors or was something confusing? Would you like me to write a post about a related topic? Any other feedback is also welcome. Thank you so much!