Spreadsheet Automation 101 - How to Automate Google Sheets · Lesson 13 of 40

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

Members-only tutorial

Watch the video and get the practice sheet with membership.

Unlock tutorials
Learn the difference between getActiveSpreadsheet() and get ActiveSheet(). Don’t get confused. Learn more with this lesson.
21 formulas linked inline Click any highlighted terms to learn more.

<div>0:00 Welcome. In this video we're gonna cover something that literally took me years to figure out and I didn't know the difference of, but I wanna get it across to you very fast and very soon.<br>0:11 Before we get any further, so in the last couple session sessions, we've done this spreadsheet app dot get active spreadsheet , and we're going down further, further into the sheet by sheet by name.<br>0:23 Get the range , get the value. Getting Started Coding in Apps Script Advanced Coding in Google Sheets for Programmers What is a Spreadsheet? Anatomy of a Spreadsheet

Well this is, this function as we have it written here is actually very good for running scripts, is what, that's what we're doing here.<br>0:32 We're automating app script and we're gonna be automating abs script in the next few sessions, in the next few lessons.<br>0:39 But I wanna point out something that this function is not necessarily the best. Turn Your Apps Scripts into Native Formulas | Apps Script Custom Function Tutorial EASY Automation is not Magic

If we are creating scripts while using the sheets, this is great for running scripts when we're not an active user, but if we are at an active user, we're gonna do something a little bit different and you can, you actually have a choice.<br>1:04 You can do it like this or we can take, get active spreadsheet and change it to get active sheet . Literally that's all we have to do.<br>1:13 Let's add a few more space so we can get that up here. So this is the same function , actually we'll do two right?<br>1:21 To make it a different function . Recall from our pre-course information. Getting Started Coding in Apps Script Activate A Certain Sheet When Opening a Spreadsheet Add New Task when Task Completed

We can only have one function as the same name.<br>1:27 Every name has to be unique . Okay? I did, there's one problem with this as is all we did is we deleted the spread from Get Active spreadsheet , but get Active Sheet is going to go to the user, whoever the user is in this case it's us right now on the sheet.<br>1:45 It's gonna get the sheet and we don't need the name. We, we, we, it'll know the name. So we actually delete this whole line here as well.<br>1:54 So get Active Sheet does sometimes seem simpler and faster, right? Cuz we're a user. Learn to Code in Google Sheets, For Programmers | For Advanced Google Sheet Users Get Tab Name in Cell

We're gonna go here, get active sheet from sheet two.<br>2:04 We don't need a range here. From Sheet we're on, let's say, actually that's a real name of it. And any time this will be a one, we're on a sheet.<br>2:15 So we'll add a new sheet. We don't have to do sheet by name. We do equals, let's see if it works.<br>2:22 And it does, right? Getting Started Coding in Apps Script Activate A Certain Sheet When Opening a Spreadsheet Add New Task when Task Completed

So what we're doing is if we want an active user to run the script, we don't need get Active sheet &lt;laugh&gt;.<br>2:33 Sorry if, if the script is an active user, meaning someone's using it right now, we do want get active sheet so we know which one we're on.<br>2:39 We don't have to put the get sheet by name, okay? It goes wherever the active user is. Getting Started Coding in Apps Script Activate A Certain Sheet When Opening a Spreadsheet Automation is not Magic

It can be sheet one, it can be Sheet two.<br>2:47 You can change the name of the sheet, get active sheet sometimes seems great, but the one problem is gonna happen when you try to run that script and no one is an active user.<br>2:58 So it's a Tiny difference. Get active spreadsheet versus get active sheet . But a big difference is that you do not need to have the get sheet by name part of this.<br>3:08 And if you have an active sheet , you have to have an active user. Getting Started Coding in Apps Script Get Sheet ID and Tab GID Into Your Google Sheet Automation is not Magic

Okay, so the first one again, get a one from Sheet one is more specific.<br>3:18 It tells us get this sheet by name, get it at this particular range . But it allows us to do that automatically all the time when we run automations and triggers.<br>3:30 Again, we'll learn that later. So, tiny difference but big possibility difference. And I didn't realize this for years, I know this now.<br>3:41 But yeah, get Active Sheet gets you the sheet that you're on as a user. Get active sheet . Getting Started Coding in Apps Script Get Sheet ID and Tab GID Into Your Google Sheet Automation is not Magic

You can get that range , you can get the value and, and you can go all the way through all the, all the steps we did before going functionally down and down, down the rabbit hole.<br>3:57 You can still do same as before. Get active spreadsheet and get active sheet . Have the same get range , get value, all the things, but it's just a little bit of a difference that makes a big difference later on.<br>4:08 Thank you for watching again. Actually, next video we're going to do our first trigger . You'll see the very first trigger we will do, which will be exciting.<br>4:18 Bite.</div> Getting Started Coding in Apps Script Automation is not Magic

Spreadsheet Automation 101: Introduction to Pre-course Videos Think Like a Programmer: Develop The Mindset of an Apps Script Coder How To Change Date Format Automatically Tips to Navigating Thousands of Lines of Code In Apps Script 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 Scoping Functions in Apps Script Breaking Through Errors In Apps Script VAR vs CONST vs CONSTANT in Apps Script