Hey there stranger!

Sign up to get access.

Spreadsheet Automation 101: Functions

About this Tutorial

Get introduced to Apps Script functions and functions syntax. Learn how to write new functions, how to name functions and call functions from your sheet.

Video Transcript

0:00 Hi, welcome. As with most of these videos, I'll be spending more time not in the sheet. We'll be spending time in extensions app script.
0:08 So let's go over there. And in this video we're gonna be talking about functions. This is just an introduction to functions and function syntax, but the very first time that we create an app script, like we open it up right here, we'll see function, my function, two parentheses and then two curly brackets.
0:26 And this is the typical syntax that you will write new functions with. So if we wanna write a new function, we will literally write the word function, then we can write a whole new function.
0:41 Then we'll add the parenthesis and it'll add the second parenthesis for you. So we can skip ahead and add curly bracket.
0:48 If you add one curly bracket on your keyboard, it'll add the other curly bracket. So we'll just hit enter to give it a little more space, a little more easier to read.
0:56 Now about functions, I want to mention some very important things. One is that when we name functions, we want to name them with camel case.
1:07 Whatever words we use here, start the first word in lower case. Then every word after that, make it so that it's a capital letter.
1:16 This will help us read these better because they, the, all of these characters need to be all in one. It needs to be one, no spaces word, but we can use multiple words if we use this sort of camel case.
1:29 And as we do this as well writing this, it helps us remember that all of the other functions inside of app script are also Camel case.
1:40 So as we'll see later, except for the first one's spreadsheet app, which we'll get into later.  Also does not have parenthesis, but if we do get active spreadsheet, you'll see here that this function starts with G E T, but lowercase G and then capital A and capital S active spreadsheet, again, it's all one word, but it's no spaces capitalized.
2:08 It's called Camel Case, right? We, we have these sort of humps and that's functions, right functions. A few other wor notes about functions as we get into this class and of course is that if you, you can only name one fun have a unique name for functions.
2:27 You can't use the same function. Again, you can't say name functions the same. You can call functions inside of functions.
2:40 So you can say new function. And what this allows you to do is write a smaller function, sort of more specific and then call that sort of any number of times.
2:49 We also have one extra thing inside of functions that is absolutely amazing is we have variables here and we can add a variable here and it can be used Anywhere.
3:00 So we can say, you know, we can do some math on this variable. We can say a new, oh, sorry, variable new word equals, and we'll get into this later, but var, right?
3:15 This var and this var actually, there you go. Paul can't use var. There are some saved words like var we cannot use.
3:23 So variable, right? We can use something here, maybe a range. And when we type in range here, this range is this range.
3:31 All functions need to do something. So you either are gonna return some, some string or some math. So we write return.
3:42 Then what happens in a function is we can return sort of anything. We'll get into variables in the next video.
3:51 But let me just do var number equals and we'll put another number one here. We can do number one plus five and we can return this variable number.
4:07 Again, we'll go over variables in the next video, but we must return something. But also we don't necessarily have to return something.
4:17 We can do something. A function nine can absolutely do something. So we can maybe do a spreadsheet app. Again, we'll go into all of this.
4:26 You'll, we can sort of do this, get sheet by name. Again, you can see all of the functions are camel case, should be sheet one, dot get range, and we'll do this, we'll go over this in detail later, but we can say in this range one one, which is a one set value, and we can set the value of number.
4:51 So this variable number will show up here. Again, I'm gonna go into variables in the next video. See you there.
4:56 Bye.

Courses

Spreadsheet Automation 101: Introduction to Pre-course Videos

Think Like a Programmer: Develop The Mindset of an Apps Script Coder

Spreadsheet Automation 101: Functions

Spreadsheet Automation 101: Variables

Spreadsheet Automation 101: Dot Notation

Spreadsheet Automation 101: Camel Case

Spreadsheet Automation 101: Parentheses

Spreadsheet Automation 101 Lesson 1: GetValue - Introduction to SpreadsheetApp

Spreadsheet Automation 101 Lesson 1: Spreadsheet Taxonomy

Spreadsheet Automation 101 Lesson 1: A1 Notation vs Row,Column Syntax

Spreadsheet Automation 101 Lesson 1: getActiveSpreadsheet() vs getActiveSheet()

Spreadsheet Automation 101 Lesson 1: onOpen() Trigger - Custom Menu

This Seems Like Automation

Spreadsheet Automation 101 Lesson 2: Get Values - Introduction

Spreadsheet Automation 101 Lesson 2: Arrays

Spreadsheet Automation 101 Lesson 2: For Loop

Spreadsheet Automation 101 Lesson 2: Bracket Notation

Spreadsheet Automation 101 Lesson 2: Logger.log()

Spreadsheet Automation 101 Lesson 2: If ( ){ } and Checkboxes

Spreadsheet Automation 101 Lesson 2: onEdit() Trigger

Introduction to Spreadsheet Automation 101 Lesson 3

Spreadsheet Automation 101 Lesson 3: MailApp

Spreadsheet Automation 101 Lesson 3: Email Yourself For Loop

Spreadsheet Automation 101 Lesson 3: Send Email Every Week Trigger

Spreadsheet Automation 101 Lesson 3: Email Other People For Loop

Spreadsheet Automation 101 Lesson 4: Access APIs Introduction

Spreadsheet Automation 101 Lesson 4: UrlFetchApp

Spreadsheet Automation 101 Lesson 4: OmdbAPI get ApiKey, get Data in URL

Spreadsheet Automation 101 Lesson 4: OmdbAPI get data in Apps Script

Spreadsheet Automation 101 Lesson 4: JSON (beautifier) and OmdbAPI parameters

Spreadsheet Automation 101 Lesson 4: OmdbAPI Parameter Picker

Automatically Clear Content | Refresh Reuse Recycle Templates

Automate Google Sheets With Zero Experience

Automatically Uncheck A Daily Checklist

Activate A Certain Sheet When Opening a Spreadsheet