This tutorial is available for all users. Start with a 7 Day Free Trial today and get access.

Hey there stranger!

Let's not be strangers any more. Start a FREE TRIAL today to view this tutorial, right now.

Why Code in Google Sheets? - Learn to Code in Google Sheets Part 1

About this Tutorial

welcome to part one of Learn to Code in Google Sheets. In this video, we're gonna get started to code.

Video Transcript

0:00 Hello, welcome to part one of Learn to Code in Google Sheets. In this video, we're gonna get started to code.
0:07 We're literally gonna open up the ID in just a few moments. But first I want to describe a little bit of why do we code, why coding in Google Sheets is important.
0:16 Why does it exist? In Google Sheets, you can enter data into any row, any column, and have those pieces of data in different cells relate to each other.
0:29 And one of the most powerful functions powerful things in Google Sheets is the formulas, right? We, you might know all the formulas, 400 of them, I think, or more than 400 of them exist.
0:42 But if you've ever found yourself saying something like, I want to do this automatically, or I wish there was a way to automatically do something.
0:51 If you ever found yourself saying that, then you want to learn to code. And it's not as hard as you think.
0:57 In this video, we're gonna do some math, we're gonna learn where to code, but if you've ever found yourself saying the word automatically or automatic or programmatic, we're gonna get you there today.
1:10 So where to code? Let's get, let's get started right now. I don't wanna waste any more time. Go up to extensions.
1:16 I've opened a brand new sheet. You can go to sheet.new. There is no magic whatsoever in this sheet. I have not done anything.
1:22 Look, last I did was edit two minutes ago. I just created the sheet. Every sheet has this extensions Go to extensions up here.
1:30 Go to App script and you're gonna open a new window. This is just one click. It's gonna open a new window.
1:36 This is where we code. It's gonna open. There we go. The very first time you ever open app script inside of a Google sheet, it will have this function already written here for you.
1:49 I'm gonna go through the structure of a function soon, but I wanna show you first what can happen. So we can rename this, let's call it math, and we can take in some number.
2:01 So we're gonna do number one, comma number two. And then we can go number, we can do a variable, variable new number equals number one, plus number two.
2:19 And we want to return new number. We're gonna hit command S. That's gonna save the project. If this orange button goes away, then we know that it is saved.
2:29 So it's saving the project. I just hit command. S can also hit this save project right here. All right, it's saved.
2:37 Now we can go back to our sheet and we can have say two numbers, like 55. This is like, and 66.
2:48 Now, if we go equals math, the thing that we wrote over here, the name Math, Math, C4 and comma 66, this c5.
3:01 Let's see what happens. What do you think? Oh, it adds it together. And we just created this right here. We can change this to divide command S.
3:10 Now that orange button goes away and C, now it's already changed. That's pretty cool, right? So we have been able to access and use cells in a function that we wrote ourselves already.
3:27 And we can do any math whatsoever. We can do plus sign, we can do divide, we can do times or multiply.
3:33 We can do minus here. We can also do many different things. We can put these in brackets and we can do divide by number two.
3:43 See, we are using variables, and I'll get into this a little bit later in the videos, but we're gonna use variables here.
3:47 New number, new number. We can name this. Anything we want, we can say no number here. It'll change it to a little grayer to know that hey, we're not using that.
3:57 But once we use it somewhere, it's there and we can just save that. And it's the exact same thing. So I want to share with you one thing before we go.
4:09 Actually two things before we go. One, this is says function inside of the sheet. Sorry. Inside of the script. Inside the sheet, If I'm ever talking about a formula, it's this equal sign.
4:21 And it can be anything. Some average. I call these formulas when they're inside of a sheet. When it's inside of a script, I call it a function.
4:29 That's my lexicon. And you'll see that many times over in these videos. Function is in app script and formula is in a sheet.
4:37 All right, What is the structure of a function? The structure of a function is that it says fun, the name function, then it can whatever the name of the function, we want to name it.
4:46 And then we have any variables we want, if we want variables. And inside these curly brackets are the function that we actually, the code that actually runs Get ready.
4:57 Cuz we're gonna get to way more in part two.