Members-only tutorial
Watch the video and get the practice sheet with membership.
About this Tutorial
Sheet Resources
Video Transcript
<div>0:00 So in the last video, we took some information from cells Learn about cells in Google Sheets and how they store data. Opens in new tab mushed up into some math and returned it.
And we are programming, we're coding inside of Google Sheets.<br>0:12 In this video, I'm going to share Discover how to share your Google Sheets with others. Opens in new tab with you how to go basically from sheet to script and then back to the sheet again.<br>0:19 Essentially we are accessing from the script the data Understand the types of data you can work with in Google Sheets. Opens in new tab that's inside of a sheet without having to put it in as we did before.<br>0:29 In this cost per melay function Explore how functions work in Google Sheets for calculations. Opens in new tab , we put C3 into the function Explore how functions work in Google Sheets for calculations. Opens in new tab On the sheet side, sometimes we wanna access a cell programmatically and we don't want to have to enter it on the sheet side.<br>0:42 We want to go based on the range Get to know how to define ranges in Google Sheets. Opens in new tab in the script, and we'll show you that.
So basically we'll go from the sheet to script and then back again.<br>0:52 I'm gonna make a new sheet actually called sheet two. I'm gonna put some data Understand the types of data you can work with in Google Sheets. Opens in new tab here and I'm gonna just call it data Understand the types of data you can work with in Google Sheets. Opens in new tab is here, some text.<br>1:00 And we're gonna access that in this video. Also, we're gonna go through the hierarchy of how code looks at a spreadsheet Learn what a spreadsheet is and its components. Opens in new tab .<br>1:08 So this will be very exciting. So let's go to our IDE or our extensions app script Find out how to use Apps Script to automate tasks in Sheets. Opens in new tab . Again, let's load this up and we're only gonna write one as well.<br>1:17 Two lines of script. We're gonna call this function Explore how functions work in Google Sheets for calculations. Opens in new tab get data Understand the types of data you can work with in Google Sheets. Opens in new tab from a one, Okay?
And we're gonna put nothing in the parenthesis here and in the curly brackets, we're gonna hit enter.<br>1:30 Once you put the curly brackets, what we wanna do is a variable called cell data Understand the types of data you can work with in Google Sheets. Opens in new tab , and we're gonna equals. Now, how do we access a spreadsheet Learn what a spreadsheet is and its components. Opens in new tab ?<br>1:41 Let me go through what the hierarchy is first, then I'll show you in the code.
So first off, the entire thing is called like a worksheet Understand the concept of worksheets within a spreadsheet. Opens in new tab or a spreadsheet Learn what a spreadsheet is and its components. Opens in new tab .<br>1:50 So there is a little bit of confusion sometimes in Google Sheets in particular, this is sort Learn how to sort data in Google Sheets effectively. Opens in new tab of something that's not in work in Excel Discover the XLSX format and its use in spreadsheets. Opens in new tab .<br>1:58 So in Excel Discover the XLSX format and its use in spreadsheets. Opens in new tab you say worksheet Understand the concept of worksheets within a spreadsheet. Opens in new tab , and then you say like sheet or tab. In Google sheets, we say spreadsheet Learn what a spreadsheet is and its components. Opens in new tab sometimes I'll say spreadsheet Learn what a spreadsheet is and its components. Opens in new tab file, and then I'll say tab for the individual sheets on a, in a sheet.<br>2:11 So what it is, is the hierarchy goes spreadsheet, which is the entire file.
Then a sheet a spreadsheet Learn what a spreadsheet is and its components. Opens in new tab inside of it, which is also called a tab.<br>2:21 Then when we get into the tab, we can access any cell with the A one notation Understand the notation used for referencing cells in Sheets. Opens in new tab , which is the n which is the notation Understand the notation used for referencing cells in Sheets. Opens in new tab across the top and across the side here.<br>2:36 Okay, so that's the explanation, but let me show you because it's much easier to show also, because Google script has auto complete here.<br>2:46 So if I just start typing capital S spreadsheet Learn what a spreadsheet is and its components. Opens in new tab , it'll say, Hey, do, do you want this? And yes, we do.<br>2:53 And what is it? Spreadsheet Learn what a spreadsheet is and its components. Opens in new tab app. This is the start of the hierarchy.
This is everything in this entire file. The Script that we're working on right now is tied to this entire spreadsheet Learn what a spreadsheet is and its components. Opens in new tab file.<br>3:06 And that's this word right here, spreadsheet Learn what a spreadsheet is and its components. Opens in new tab app. We hit it the dot or period. Then we say get. And in this case, we want to do active sheet Learn about the active sheet and how to interact with it. Opens in new tab because we're gonna use this function Explore how functions work in Google Sheets for calculations. Opens in new tab inside of a sheet.<br>3:23 We wanna add on this one parentheses. That's one key thing you gotta know right here is that this get active sheet Learn about the active sheet and how to interact with it. Opens in new tab needs to add parentheses.<br>3:32 You'll get an error Explore common errors you might encounter in Google Sheets. Opens in new tab if you only do this without the parentheses.
Then now that we have the entire spreadsheet Learn what a spreadsheet is and its components. Opens in new tab file and we're, we're on the sheet that we are active in that our formula Get familiar with the syntax used in Google Sheets functions. Opens in new tab is gonna be in, we do get range Get to know how to define ranges in Google Sheets. Opens in new tab , and then we say a one in quotes, and then we do get value.<br>3:55 So the value, let me move my face here. The value here is the actual value inside of the cell, either text or a number Learn how numbers are handled in Google Sheets. Opens in new tab .<br>4:03 And then we're gonna finish that with the semicolon. You don't necessarily need to do that. Now all we need to do is return sell data Understand the types of data you can work with in Google Sheets. Opens in new tab .<br>4:11 We're gonna hit command S to save. Now that orange button goes away.
Now we can use this, get data Understand the types of data you can work with in Google Sheets. Opens in new tab from a one anywhere we want.<br>4:18 So we can do equals get data Understand the types of data you can work with in Google Sheets. Opens in new tab from a one, do the parenthesis, hit enter, and there we go. In E four, we now have what's in a one.<br>4:30 Now if we want to change that range Get to know how to define ranges in Google Sheets. Opens in new tab , this a one based on what we enter in the sheet, we can actually put a variable inside of this parenthesis here called range Get to know how to define ranges in Google Sheets. Opens in new tab and use that instead of a one, we can say range Get to know how to define ranges in Google Sheets. Opens in new tab Hit command S.<br>4:48 Now in, we get an error Explore common errors you might encounter in Google Sheets. Opens in new tab .
Now in our sheet, we're gonna write in here in quotes a one, and we're gonna get the exact same answer.<br>4:57 Data Understand the types of data you can work with in Google Sheets. Opens in new tab is here, and then we can also get a, we can change this to a two anywhere here. That'll get us, get us what's here.<br>5:04 Hello? Actually it already got it. So we need to go back and change a three. There we go. Height. And that's right there.<br>5:14 Sometimes we wanna programmatically or automatically access this kind of data Understand the types of data you can work with in Google Sheets. Opens in new tab that's in our script here.
And we're gonna make one change for the next video.<br>5:24 To set up the next video, we're going to add ta sorry, edit this. Get active spreadsheet . We're gonna change it to get active spreadsheet instead of get active sheet Learn about the active sheet and how to interact with it. Opens in new tab .<br>5:36 Why I do that is so that we can run this script from Google servers. We never, we don't have the sheet open.<br>5:46 So this sh script should still work here. Let's double check.
It does still work here, but now what's gonna happen in the next video is we're gonna automatically we're gonna use this automatically, programmatically.<br>5:59 So get ready, get started. See you.</div>
Courses
Why Code in Google Sheets? - Learn to Code in Google Sheets Part 1
Tips to Navigating Thousands of Lines of Code In Apps Script
How to Write a Function - Learn to Code in Google Sheets Part 2
From Sheet to Script And Back Again - Learn to Code In Google Sheets Part 3
Copy That, From One Sheet to Another - Learn to Code in Google Sheets Part 4
Now Do It Every Damn Day - Learn to Code in Google Sheets Part 5
Wrap Your Mind Around This - Learn to Code in Google Sheets Part 6
Write Your First Script
00:08:31
How to Record Macros
00:06:20
How to Edit a Macro
00:08:22
How to Trigger Macros Daily
00:06:58
Automatically Uncheck A Daily Checklist
How do I reference a different spreadsheet in Apps Script?