Members-only tutorial

Watch the video and get the practice sheet with membership.

See membership options

Why Different Cell References in AI Integration in Sheets?

About this Tutorial

Find out How to Optimize your Apps Script functions. Learn the trade offs between flexibility, edit-ability, and protection. Different cell references allow you to do more with your apps script.

In the context of the video we're talking about an AI prompt and how I used different Cell References when writing different Apps Script functions. I'll show you why I chose those syntaxes and why you might choose different ones.

This video is more about Apps Script than writing Prompts but can help you create better web apps inside of Google Sheet, utilizing the best of Apps Script and creating your own custom functions.

Video Transcript

<div>00:00 Hello, oh, so, Terence, BetterSheets member Terence, had a question about cell references Learn about different types of references in Google Sheets and how they impact your formulas. Opens in new tab . When I have been doing AI integration inside of Sheets and sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of writing a GPT function Understand what functions are and how to use them in your Google Sheets. Opens in new tab or writing sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of just open AI function Understand what functions are and how to use them in your Google Sheets. Opens in new tab we have this function Understand what functions are and how to use them in your Google Sheets. Opens in new tab here, we have function Understand what functions are and how to use them in your Google Sheets. Opens in new tab , it's literally- called<br>00:20 AI, and then we have the prompt, some text here.

And he was asking, you know, he's been following three or four or five different videos where Explore the query function and how to use the WHERE clause for data filtering. Opens in new tab I talk about AI, and he probably hasn't seen yet this video where Explore the query function and how to use the WHERE clause for data filtering. Opens in new tab I create sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of a, a chat- it sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of looks like a chat interface, but what it really<br>00:39 is is to look at all- of your prompts in a row and see which ones are good or bad. And this one might actually surprise him because it doesn't have a function Understand what functions are and how to use them in your Google Sheets. Opens in new tab inside of B2 here.<br>00:51 Where Explore the query function and how to use the WHERE clause for data filtering. Opens in new tab we write this prompt, we, we execute a function Understand what functions are and how to use them in your Google Sheets. Opens in new tab that's completely separate.

So this user fun- this user experience might be very interesting.<br>01:01 But he was looking at, Terrence was looking at past videos where Explore the query function and how to use the WHERE clause for data filtering. Opens in new tab I wrote a custom function Understand what functions are and how to use them in your Google Sheets. Opens in new tab called openAI and then had some prompt in here, but had a variety of different cell references Learn about different types of references in Google Sheets and how they impact your formulas. Opens in new tab across many different videos.<br>01:18 Sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of each video I made a different way. One time I did Q and then I wrote ampersand A1 and then ampersand and then had space A and then had this.<br>01:39 This sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of fun, this sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of. Syntax Get familiar with the syntax rules for writing formulas in Google Sheets. Opens in new tab here.

Let me sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of try to make this a little bit bigger.<br>01:46 And with this syntax Get familiar with the syntax rules for writing formulas in Google Sheets. Opens in new tab , I think the reason I did this is because that is literally how the AI prompt was written.<br>01:53 I was actually using an example from open AI's own documentation and they said, you know, make the prompt in this way.<br>02:00 Put Q.

Put your question and then put literally the text a colon and that's the end of your prompt and then it will complete because what this AI is doing and what this LLM is doing is text completion.<br>02:15 It is taking this question and answer going from a colon and then just completing. That it is not necessarily answering the question.<br>02:25 It is saying what in this vast database of knowledge would be the next token after a after this answer or what would be this answer.<br>02:38 And so that was what I originally did and then.

I've been sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of doing different cell references Learn about different types of references in Google Sheets and how they impact your formulas. Opens in new tab like for instance, right now for this particular app script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab , which is just AI prompt.<br>02:54 I know in my head and how I wrote this app script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab , I know that all I need is the prompt.<br>03:00 I don't need to add any more. I need to add any more extra curricular information with the GPT function Understand what functions are and how to use them in your Google Sheets. Opens in new tab that I wrote.<br>03:07 I put all of the tokens, the temperature, the top P, the frequency penalty, the presence penalty. I put that all in here.<br>03:14 So I needed to reference Learn about referencing cells and ranges in your Google Sheets formulas. Opens in new tab all of those cells Understand the structure of cells in Google Sheets and how to manipulate them. Opens in new tab to get all that information into the function Understand what functions are and how to use them in your Google Sheets. Opens in new tab name.

But for this particular app script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab , I needed to add any more function Understand what functions are and how to use them in your Google Sheets. Opens in new tab , AI, that I wrote.<br>03:26 I literally just need the prompt. I don't need to put in all of this. I could write this app script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab where Explore the query function and how to use the WHERE clause for data filtering. Opens in new tab all of this message is some kind of variable here.<br>03:42 And then I write message here, and in this case, I would need to recreate all of what I just deleted.<br>03:49 I would need to write in all of here, in here probably in quotes. Whoops. That's the APA. There it is.<br>04:04 I would need to put into the cell, into the cell here.

But right now, because I wrote this function Understand what functions are and how to use them in your Google Sheets. Opens in new tab as just ai prompt, and then put this prompt variable in here on line seven, I only need to put in some question, or write, I can put in.<br>04:22 Here, write, write a summary of the ten commandments in three words. I don't think this is gonna work, but we'll see.<br>04:36 There we go, done. Right? I just have some text, put in quotes, and that's it.

But now I'm like, I have to, I need to write this equal sign, ai, I need to write anything I want to write, I have to go into these quotes, between these double quotes, and I have to write it.<br>04:52 What I really want to do is use all of the power of Google Sheets. I want to utilize anything and everything.<br>05:00 I want to utilize multiple variations of, this. So I want to start doing cell references Learn about different types of references in Google Sheets and how they impact your formulas. Opens in new tab . I want to say, okay, I'm going to reference Learn about referencing cells and ranges in your Google Sheets formulas. Opens in new tab , actually, I'm going to put in a1 the prompt.<br>05:13 What it summarize the 10 command, let's do that, in five words.

That's the prompt I want to do. So I'm going to do equals, in b2, I'm going to go over here, ai, and I'm just going to do cell reference Dive into cell references and how they can change when you copy formulas. Opens in new tab a2.<br>05:30 That is all I have to do. I don't have to put in any extracurricular information. I want to make this as simple as possible, and I have done that by way of the function Understand what functions are and how to use them in your Google Sheets. Opens in new tab .<br>05:41 But sometimes, maybe there's other things, so we'll, talk about that in a second. But let's just get this done, right?<br>05:45 We have a cell reference Dive into cell references and how they can change when you copy formulas. Opens in new tab to a2. And here's the answer, right? There's five words.

What if, for instance, this is a good example, a2, just putting a2 in.<br>05:57 If I'm like, I'm going to write the whole thing here, and if I copy and paste this down, I'm going to have a blink.<br>06:02 This is going to be a3. I have nothing here. But I want to maybe copy and paste this and put in ten words.<br>06:09 Maybe I want to do in twenty words, and I'm going to, Or maybe I want to even do in three bullet points.<br>06:23 See if that does, That's it, right? So I can also, Yeah, let's do that. Let's make this a little easier to read.<br>06:33 See everything. Right?

So now I'm referencing this A2 here. I'm referencing A3, but what if, What if I was like building some kind of, interface, and I was like, this is gonna be some other user, or me in the future, and I'm like, I know in this particular sheet, with this particular Apps Script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab , I'm<br>06:56 gonna write summarize the 10 commandments, and I'm always gonna have some variable here.

Okay, so in this case, I can cut that, summarize the commandments, the thing that's the same thing, all the way through, I can just put that, right here, in the B2, right, in the function Understand what functions are and how to use them in your Google Sheets. Opens in new tab , put the ampersand&nbsp;<br>07:18 I know I'm gonna use the word in, and now all I have to do, I can copy all of this down, is write 10 words, actually I need a space, right after the in I don't need the period, I don't need that, I need 20 words, 3 bullet points, in, maybe I wanna do in 10 emojis, something like that, right<br>07:49 , so now I know I am building this sheet, that is the 10 commandments summary sheet, I know the prompt is summarize the 10 commandments summary, and that x is a2 or a3, but like.<br>08:05 You know, this is a different use of this prompt, okay, I am getting maximum execution time, oh, it is probably because I just did it all at the same time, this is actually wrong, three bullet points ends up being 10 bullet points right, so now we have this.<br>08:25 We are using this in a different way, right, we are using Google Sheets to do the prompt, we have some text in the function Understand what functions are and how to use them in your Google Sheets. Opens in new tab here, we have some text and syntax Get familiar with the syntax rules for writing formulas in Google Sheets. Opens in new tab in the app script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab , right, we have this role system, we can also write our role.<br>08:45 Here we can say something like, you are an expert in the ten commandments, you can, you write like Charles Bukowski, I don't know no, probably, maybe Shakespeare, you write like Shakespeare, and I am, bic- pentameter.<br>09:09 You tell it like it is.

I don't know, this is all crazy talk, but in this role, maybe this role, we want to, this is the system role we want to edit that on the fly, we want a different system role all the time, so we'll add that.<br>09:25 To our function Understand what functions are and how to use them in your Google Sheets. Opens in new tab , so in this case we're going to see, is there any actually difference? Okay, so there actually is a sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of a little, those emojis are hilarious, right?<br>09:40 Maybe we want to do a different system role, right? So instead of putting. This here, I'll just comment Learn how to add comments in Google Sheets for better collaboration. Opens in new tab it out.<br>09:47 We're going to do prompt comma role.

And now in our function Understand what functions are and how to use them in your Google Sheets. Opens in new tab , we need another column here that says system. You are Salvador.<br>10:05 Salvador Dali. You are a member of the Starfleet Academy in Star Wars. Right? And in our here we need actually two things.<br>10:28 We need B2, comma, and then the actual plot. We're the Bible, right? Put that there. Copy all these down. And now, right, we have different information all over.<br>10:54 We have messages, we have role prompt, we have that prompt and role here in our function Understand what functions are and how to use them in your Google Sheets. Opens in new tab .

We write it in here in our function Understand what functions are and how to use them in your Google Sheets. Opens in new tab here.<br>11:01 We have a little bit of text here, and then we put our system function Understand what functions are and how to use them in your Google Sheets. Opens in new tab here. Prompt here. Actually, it's not our prompt, it's our sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of input.<br>11:12 Okay, we are getting some weird answers Explore how to use Google Sheets to find answers to your data questions. Opens in new tab here. I am not solving our dolly. I have a language model. Oh, that's creepy.<br>11:22 Great. So, you know, we can have all this. We can have all this information in many different places, and it's our choice to put it in different places based on what is the user want.<br>11:33 Are we building this for ourselves?

Do we just want a very simple prompt writer? We might. We might do that by just not having the role here in our function Understand what functions are and how to use them in your Google Sheets. Opens in new tab name.<br>11:46 And we might just put the variable role here as nothing, and we're just going to get the prompt. And we don't need all of this column we just need here.<br>12:03 And maybe we do want to write the entire, we want to. See the entire prompt. If we're writing this, if we're creating this app inside of a Google Sheet for other people.<br>12:15 Say it's our own organization.

We don't necessarily need to write the prompt in Apps Script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab to sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of hide Discover various formatting options to enhance the appearance of your Google Sheets. Opens in new tab it.<br>12:25 We might want to write it here because we want. Some flexibility. We want to edit it at some points, but we don't necessarily need the user to see exactly that prompt.<br>12:34 They can definitely have access to it. And putting it in text in sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of A2 all together. That means every single time we sit here and write, we have to write it out.<br>12:46 We have to. Write out all of that stuff, but maybe we have half the prompt.

Or we have some examples and we're like, you know, we just want those examples somewhere.<br>12:55 We can even put them on a completely different sheet. We can say examples, right? And point to this example in A1 and combine Learn how to merge cells in Google Sheets for better data presentation. Opens in new tab it here.<br>13:06 In our prompt. We can say and examples include. Ampersand. Examples. A1. Right, and if there were some examples there. It would include that in the prompt in the function Understand what functions are and how to use them in your Google Sheets. Opens in new tab .<br>13:25 We have a reference Learn about referencing cells and ranges in your Google Sheets formulas. Opens in new tab to it. Right, so if somebody were coming in here and say I want to edit these examples.<br>13:31 Where Explore the query function and how to use the WHERE clause for data filtering. Opens in new tab would I edit it? They would look at this. B2.

They say oh, here's examples. A1. They can follow the chain.<br>13:38 Okay, so it's a little bit harder to edit. In theory. But it actually ends up being easier to edit because literally I'm like I just want to edit the examples.<br>13:47 Okay, go here, do examples, and write input. Three words. Put response. Do not murder. Kill. Right. I don't know if that was, that's an actual one, but.<br>14:06 There we go. So that's interesting.

So we can use all of the power of Google Sheets in a number Understand how to work with numbers in Google Sheets and perform calculations. Opens in new tab of different ways for a number Understand how to work with numbers in Google Sheets and perform calculations. Opens in new tab of different reasons, right?<br>14:14 I would say, sort Discover how to sort data effectively in Google Sheets for better organization. Opens in new tab of all of these things, balance, protection Find out how to protect your Google Sheets data from unwanted changes. Opens in new tab versus editability versus flexibility.. And you can be as flexible, as editable as you want.<br>14:28 Or, not at all. You could take all of this and everything not the API, in cell reference Dive into cell references and how they can change when you copy formulas. Opens in new tab . You could not have a prompt here.<br>14:37 And you could say, and right here, variable prompt equals, And you could go ahead and write your entire prompt.

Everything you want to put in.<br>14:48 Examples you want to put in styles, you want to put in tone. All of that right here. You can put all of your role in here.<br>14:53 The entire system you can put it all in Apps Script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab . And then the user, all they can do is write AI and they'll get, they'll get something.<br>15:04 Maybe your temperature is one. Maybe you're like, okay, every time that you put in AI. I put in this prompt.<br>15:10 We want a different result. We want, you know, different things.

Maybe we increase the max tokens, but we don't want this necessarily editable.<br>15:19 It is editable. I can edit it. I'm editing it right now. But someone who was familiar with Google Sheets. Might not know exactly, they might know that Apps Script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab exists, but they might not know that your AI is editable in Apps Script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab and where Explore the query function and how to use the WHERE clause for data filtering. Opens in new tab to do that.<br>15:40 They can't tinker around with it. Tamper with it. If you want to make it easily findable in.

Typeable, because maybe you have this function Understand what functions are and how to use them in your Google Sheets. Opens in new tab , it's not AI, maybe it is write the 10 commandments in a funny way.<br>16:02 This is a horrible way to do it, but maybe that is the function Understand what functions are and how to use them in your Google Sheets. Opens in new tab . What I think it is. Is, I'm gonna do this on the fly, I'm gonna do a comment Learn how to add comments in Google Sheets for better collaboration. Opens in new tab , at custom function Understand what functions are and how to use them in your Google Sheets. Opens in new tab .<br>16:14 And now, if I start typing in here, write, there it is, write the 10 commandments in a funny ways. And maybe you have two functions Explore the various functions available in Google Sheets for data manipulation. Opens in new tab , right?<br>16:26 Maybe you have another function Understand what functions are and how to use them in your Google Sheets. Opens in new tab called. Write it in a silly way, write it in a serious way.

And you create these functions Explore the various functions available in Google Sheets for data manipulation. Opens in new tab that someone, all they have to do is write this, write the 10 commandments in a funny way.<br>16:37 And bam, they get a response.

They don't know it's AI, they don't care, they don't care all of your prompt, they don't care everything, but they do have access to it, right?<br>16:44 Anyone who has access Learn how to manage access permissions for your Google Sheets. Opens in new tab to it is trading off a lot of protection Find out how to protect your Google Sheets data from unwanted changes. Opens in new tab , but not 100% protection Find out how to protect your Google Sheets data from unwanted changes. Opens in new tab , for editability, for the person to write it, for flexibility as well.<br>16:57 And if you watch, the complete opposite of this particular function Understand what functions are and how to use them in your Google Sheets. Opens in new tab that I have written right here is the GPT function Understand what functions are and how to use them in your Google Sheets. Opens in new tab in another video which I write the GPT function Understand what functions are and how to use them in your Google Sheets. Opens in new tab .<br>17:05 And literally write all of the possibilities of roll the- the prompt, the model, the temperature, all of that is in the function Understand what functions are and how to use them in your Google Sheets. Opens in new tab variables.<br>17:14 And you have to put those in if you want to use this function Understand what functions are and how to use them in your Google Sheets. Opens in new tab inside of Google Shades.

In a funny way.<br>17:29 Here are three examples. And we're gonna write the three examples. And maybe we write in the tone of George Carlin.<br>17:39 I mean, that's particularly funny. But write in, in the style of some. Other Richard Pryor, right?. Write three sentences. Make them full sentences, right?<br>18:01 No, not bullet points, not anything else, not emojis, right?. We can write that entire prompt here and we don't have to put any in.<br>18:09 Puts in there. And almost the complete opposite is the GPT function Understand what functions are and how to use them in your Google Sheets. Opens in new tab that I wrote.

That includes all of the functions Explore the various functions available in Google Sheets for data manipulation. Opens in new tab parts of the functions Explore the various functions available in Google Sheets for data manipulation. Opens in new tab , all in the particular order.<br>18:20 But also, you can put prompt here, right? You can say, oh, I don't want it in here. I want to be able to edit it.<br>18:29 So I'm gonna, write here prompt, and I'm not gonna write the 10 commandments. I'm gonna write write. Maybe I just want to say write.<br>18:37 Now, You go equal, right? Oh, you need to, get saved. Yeah. Equals, right? And that's all we have. It's right.<br>18:49 Our prompt. Prompt goes here. Right? So, we can put this information in many different ways.

We can use app app script Find out how to automate tasks in Google Sheets using Apps Script. Opens in new tab .<br>19:00 We can use Google Sheets. Also check out if you haven't yet. Spin text, content spinner. This might help you a lot.<br>19:09 So instead of doing, Like this kind of thing, you would do equals spin all. Some text that is like 10, 20, 30 words.<br>19:33 And so just by doing that, just typing in this spin syntax Get familiar with the syntax rules for writing formulas in Google Sheets. Opens in new tab , this curly brackets, 10, 20, 30 words it automatically creates those there for you.<br>19:44 So you can spin some interesting content here. I'll save that. You should watch that video as well.

About the spin tax.<br>19:52 And it's a free Google sheet add-on Discover how to enhance Google Sheets functionality with add-ons. Opens in new tab you can add to your Google sheet. Anyway, alright thanks for watching and I hope this answers Explore how to use Google Sheets to find answers to your data questions. Opens in new tab your question to some extent of why do we put that why do we use self references Learn about different types of references in Google Sheets and how they impact your formulas. Opens in new tab ?<br>20:03 Where Explore the query function and how to use the WHERE clause for data filtering. Opens in new tab do we put that self reference Learn about referencing cells and ranges in your Google Sheets formulas. Opens in new tab ? We are trading flexibility or trading editability and protection Find out how to protect your Google Sheets data from unwanted changes. Opens in new tab against. Somebody else editing, tampering it or ourselves.<br>20:14 Oh, we might want to edit edit.

We might want to prevent our future selves from editing something or just making it a step or two harder.<br>20:24 It is not, you know, completely fixing protecting this text from someone. So. Hopefully that answers Explore how to use Google Sheets to find answers to your data questions. Opens in new tab your question. Bye.</div>

Courses

Sheet Stories / Video Notes + ADDED: Email Notifications

00:00:00

Fast FAQS

Enter Google Drive File Name Get URL

ChatGPT Clone in Google Sheets Part 2

Create an Internal Google Sheets Add-on

Tweet From a Sheet

Why Different Cell References in AI Integration in Sheets?

Show Sheet Tabs Based on Edit

Add Title Case to Google Sheets

How to Power Testimonials with Google Forms and Sheets

Getting Started Coding in Apps Script

Seek Errors When Coding Apps Script

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

ChatGPT Clone in Google Sheets Part 1

Embed a Number in a Website from a Google Sheet

Create Navigation Like A Book or Presentation

Add Click Tracking To Your Google Sheets | Bitly in a Google Sheet

00:29:08

Hold a Giveaway Raffle in a Google Sheet

Quickstart Tutorial OpenAI API in Google Sheets

Capture Emails from Website Form to a Google Sheet (Without Zapier)

Embed a Headline in a Website from Google Sheets

Create a new Spreadsheet from just a Name in a Sheet.

00:05:21

Bjarne Asks: Can I show the Last Time of the Last Edit in a sheet?

00:05:43

Email Yourself a Cell from a Google Sheet, Every Day

OpenSea Data Inside Sheets

Create an Email Campaign Stats Calculator

00:35:13

Twitter App Clone in a Google Sheet

Dylan Asks: How to Automatically Delete Rows If Cell Contains Value

Highlight Row as You Move Your Cell Selection

Create a Timer with Apps Script

LinkTree in a Google Sheet

00:11:22

Password Protecting Data In a Google Sheet

Automatic Weekly Backup of Google Sheets

Create a CPM Custom Function (Create Better Calculators!)

Move Entire Row when a Cell is changed to "Yes" - The $75,000 Google Script

00:12:29

What Can You Automate in Google Sheets? Every single trigger available to Google Sheet users

Sync Two Tabs Without ImportRange()

Google Sheets Stories? No! But we'll add timestamped video notes to your google sheets.

00:00:00

Password Protecting Data In a Google Sheet Part 2 The Basics

Benoit Asks: How to Convert Case

00:07:35

Learn to Code in Google Sheets, For Programmers

Add a Checkbox to Turn on Dark Mode

00:05:10

Write Your First Script

00:08:31

Find Keywords in Any Column. Create quick search dropdown to find keywords

00:09:37

Basic CRM - Add a Powerful Script To Move Row Based on Status

How To Improve: 1,000 Business ideas: Business Idea Generator

00:11:20

Let's Make a Bookmarklet!

00:12:37

Troubleshooting Bitly in a Google Sheet Script

00:07:07

Unique Features - Design a Better Dashboard Part 2

00:04:13

How To Set Up Stripe Webhook to Google Sheets with Google Script

00:22:10

How to Edit a Macro

00:08:22

Sheet Stories / Video Notes + Clear 24 Hour Old Videos

00:35:10

Add A Timestamp to Task Lists (without Now Formula)

00:07:44

Make your Custom Functions Like Native Functions | Custom Function Autocomplete

00:17:58

Create a Changelog Between 2 Cells Custom Function | To learn Double For Loop

00:23:26

New Syntax for WhatChanged Formula in Google Script

00:07:14

How to Record Macros

00:06:20

2 Ways to Delete Lines Quickly (CAREFUL, it's a script!)

00:09:53

Deep Inside Dark Habits Google Script

00:18:54

How to Trigger Macros Daily

00:06:58

5 Ways to Create Coupon Codes | Create UUIDs

Create a Radio Button From Checkboxes Using Google Apps Script

00:15:01