Hey there stranger!

Sign up to get access.

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

About this Tutorial

Learn the difference between getActiveSpreadsheet() and get ActiveSheet(). Don’t get confused. Learn more with this lesson.

Video Transcript

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.
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.
0:23 Get the range, get the value. 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.
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.
0:39 But I wanna point out something that this function is not necessarily the best. 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.
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.
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?
1:21 To make it a different function. Recall from our pre-course information. We can only have one function as the same name.
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.
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.
1:54 So get Active Sheet does sometimes seem simpler and faster, right? Cuz we're a user. We're gonna go here, get active sheet from sheet two.
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.
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.
2:22 And it does, right? So what we're doing is if we want an active user to run the script, we don't need get Active sheet <laugh>.
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.
2:39 We don't have to put the get sheet by name, okay? It goes wherever the active user is. It can be sheet one, it can be Sheet two.
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.
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.
3:08 And if you have an active sheet, you have to have an active user. Okay, so the first one again, get a one from Sheet one is more specific.
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.
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.
3:41 But yeah, get Active Sheet gets you the sheet that you're on as a user. Get active sheet. 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.
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.
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.
4:18 Bite.

Courses

Spreadsheet Automation 101: Introduction to Pre-course Videos

Automate Google Sheets With Zero Experience

Automatically Clear Content | Refresh Reuse Recycle Templates

Spreadsheet Automation 101: Functions

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

Automatically Uncheck A Daily Checklist

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