Academy ↓
Hey there stranger!
Sign up to get access.
Wrap Your Mind Around This - Learn to Code in Google Sheets Part 6
About this Tutorial
Sheet Resources
Video Transcript
0:14 I have lots of videos about each of these in better sheets and I have an entire course called spreadsheet automation about all of this, sending email accessing APIs.
0:25 That goes a lot deeper and a lot further. But I just wanted to introduce you to these concepts in case you wanna read about it yourself and know where to go.
0:35 So one thing you can do in Google Sheets is record macros. If you don't know sort of how to express a sheet or a cell or a row inside of app script, this is a good way to see it.
0:48 So go to extensions macros, record a macro right now it's recording. You can use absolute or relative references. We're gonna select this B column.
0:58 We're gonna bold it and you can see this action one set formatting save. We're gonna say bold column B. Let's see what happens.
1:09 We can also go up to extensions app scripts and here you'll see that there has been created a sheet called macros.gs.
1:19 Go there and see via sorry, var spreadsheet, Get active spreadsheet dot get range, B2B activate spreadsheet, get active range list set font weight, so that by bolding, by creating this macro for bolding, I now know the function, the Google script function, the script function for bolding, which is set font weight, bold, pretty cool way to start to learn more code and what is possible in sheets.
1:52 We can also send emails via mail app. So if we go back to our code here, just going to go function can call, we can call this anything we want.
2:02 Email some people. I'm gonna put those curly brackets there. And all we're using is this class mail app. So in Google app script developers.google.com gives you a little sample of a send email.
2:16 I like to actually use this part because we want to add some variables. So we go mail, app caps, dot send, email recipient, subject body.
2:27 That's all we need to send an email. So we do variable recipient equals andrew better sheets.co. We can say subject equals hello there in the body.
2:43 We can write, this is the body of the email command s. Now I'm gonna run this from here. I'm gonna need to authorize it.
2:51 Of course, I'm gonna move this over a little bit, but I'm gonna change this to email. Some people click run.
2:58 We're gonna have to auto authorize it and you now know how to access a cell inside of a sheet from earlier videos.
3:07 So you can actually use these variables and send data from inside the sheet through email to someone. So I just got this in my email and you'll see this in my inbox here.
3:18 Hello, there's a subject to Andrew be sheets.co. And this is the body of the email. See, it actually sends the exact email that I sent, that I wrote.
3:28 You can also access APIs via URL fetch app. So this is literally URL fetch app dot fetch, and you can grab a website.
3:38 And in this particular case, in Google App script example, they're going to google.com and they're getting the text, the html code of that Google homepage.
3:50 So you can go to website and grab that data. Pretty darn cool. I wanted to introduce you to simple versus Installable triggers.
3:59 So a simple trigger is something like the function on edit that you can name here. Now, every time there's an edit inside the sheet, this script will run, can edit from the point of view of a user if you want.
4:13 The more interesting triggers, they're called installable. Triggers can add a trigger. And these are event sourced from spreadsheet, we have the on open.
4:27 So every time a spreadsheet is open, every time there's an edit or a change in the structure of the spreadsheet or a form submit, you have those four options.
4:35 These are installable triggers and we can write the code and then we can install those triggers to run. Pretty cool.
4:42 Versus here, this is what's called a simple trigger on edit. You have also function on selection change. There we go.
4:55 You have some, a few already in app script here we can create a new sheet inside of a spreadsheet. So we can say new sheet name here, we can run this, create new sheet, run it.
5:11 And we can see here, actually this takes a little bit more, we gotta create it and then dot set name.
5:22 Sorry, what I meant was you create a new sheet in your drive. So this spreadsheet app dot create new spreadsheet name actually creates it in your drive.
5:30 Here's new sheet name. So in this video I shared with you how to record macros, where to edit those macros inside of app script At recording macros gives you a really cool insight into how a sheet functions with App Script.
5:46 I introduce you to the idea of mailing emailing from sheets and actually accessing all of the web through URL fetch app.
5:54 You can access APIs that way, and I Introduce you to the idea of simple and insolvable triggers and you can create new spreadsheets from the spreadsheet that you're in.
6:04 So this is all to introduce to you the idea that there is more to learn much, much more, much more to get introduced to much more, to do, much more.
6:17 You can automate, you can automate in so many different ways, and I'm really excited because you're on your way to coding even more.
6:25 Check out my my class or course or workshop called Spreadsheet Automation. Really excited for you to keep learning by.
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?
Topics