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.

Then, select Tools > Script editor.

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

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

There are four 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.
  • There is a menubar at the top. This menubar has various menu items such as File, Edit, View, Run etc.

You'll notice the following code in the editor:

function myFunction() {


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 play icon. Go ahead and try clicking play.

You'll notice that clicking play does nothing. 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 }.


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 try running myFunction again by clicking the play icon.

Did anything happen? Although it might seem like nothing happened, something did actually happen. Your code wrote an entry to its log. To see this entry, select View > Logs.

A popup window will display the entry 101 that your code made. You'll also see the time at which the entry was made. Click [OK] to close the window.

Pro tip: Use the keyboard shortcut CTRL + ENTER to view the logs instead of using the View menu.

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!