Members-only tutorial

Watch the video and get the practice sheet with membership.

See membership options

Add Autocomplete with Custom Function

About this Tutorial

We'll make sure our additional custom formula acts like a native formula with autocomplete in a cell.

Video Transcript

<div>0:00 We're not gonna do the, I think, is the coolest thing in Apps Script Learn about Apps Script and how it enhances Google Sheets functionality. Opens in new tab . If you ask me what is my favorite formula Explore the syntax rules for writing formulas and functions in Google Sheets. Opens in new tab , I would say the if formula Explore the syntax rules for writing formulas and functions in Google Sheets. Opens in new tab .<br>0:09 If you ask me what is my favorite thing to do in Apps Script Learn about Apps Script and how it enhances Google Sheets functionality. Opens in new tab , it is this. We're going to turn our unknown function Understand what functions are and how to use them in your spreadsheets. Opens in new tab into a custom function Understand what functions are and how to use them in your spreadsheets. Opens in new tab that acts just like a native formula Explore the syntax rules for writing formulas and functions in Google Sheets. Opens in new tab in Google.<br>0:20 Google Sheets. It's pretty darn cool and it's so easy. It is unbelievably easy. Okay. In, just before your function Understand what functions are and how to use them in your spreadsheets. Opens in new tab , just hit enter once.<br>0:33 Right here, we're gonna add a comment, but not in the way that we usually do, like, two slashes.

Just add slash.<br>0:40 So, so some slash and then we're gonna add two asterisks. It will auto complete that there is this asterisk and then a slash.<br>0:49 And inside of this, we can hit enter. Now we have these comments Discover how to add comments in your code for better readability. Opens in new tab in this sort Find out how to sort data effectively in Google Sheets. Opens in new tab of comment Learn the different ways to add comments in your Google Sheets. Opens in new tab section. And this is typically, if you wrote, you can write some comments Discover how to add comments in your code for better readability. Opens in new tab here and it will not affect the this formula Explore the syntax rules for writing formulas and functions in Google Sheets. Opens in new tab at all.<br>1:04 It's great for writing long form comments Discover how to add comments in your code for better readability. Opens in new tab if you're trying to give some message to someone, especially if you're sharing Get tips on sharing your Google Sheets with others. Opens in new tab sheets and stuff.<br>1:10 I do this fairly regularly. But here's the thing we're gonna do today.

And right now we're gonna do an at sign and then we're gonna write custom.<br>1:19 No space we're gonna not no space. Function Understand what functions are and how to use them in your spreadsheets. Opens in new tab at custom function Understand what functions are and how to use them in your spreadsheets. Opens in new tab . And if we just hit save, let's save project here.<br>1:27 And now we go and use. Remember we had the CPM inside of our sheet here. Right there. We want that CPM.<br>1:36 We wrote it and it was, it had a red line. Now we do equals CPM and it is. Auto completing right here and we can tab to accept it.<br>1:45 Isn't that fantastic? Isn't that amazing? So there are some extra information that you can do.

The minimum and the bare minimum to use this is the at custom function Understand what functions are and how to use them in your spreadsheets. Opens in new tab .<br>1:56 But Google workspace has a little bit of other functions Dive into the various functions available in Google Sheets. Opens in new tab you can add. You can add a description. We will do right now.<br>2:02 We will just add a little description. Calculate calculate cost per me like. And I'm going to add CPM in there.<br>2:11 And now if we go back to our CPM function Understand what functions are and how to use them in your spreadsheets. Opens in new tab equals CPM there, Calculate cost per me like CPM. You might want to as well have the.<br>2:22 So that's something we might want to do. The parameters Understand parameters and how they affect your functions. Opens in new tab here and the return.

So you might see that in another video.<br>2:30 Actually, I should rename this units. I don't know. I don't really like this units name. I just realized we can see a whole lot here.<br>2:38 The user is going to see a whole lot in your custom function Understand what functions are and how to use them in your spreadsheets. Opens in new tab . So if you just start typing, it'll be cost and units.<br>2:44 And I think this is too general. It also says if you see here this object object, which we want to change.<br>2:49 So I will edit that now to views. And then we need to change this as well to views.

We need to add some parameters Understand parameters and how they affect your functions. Opens in new tab here too.<br>2:59 If you see here, we can add extra parameters Understand parameters and how they affect your functions. Opens in new tab and the description of them here. So we can add views and cost.<br>3:10 Save that. And we can see here, we want to give a better user experience if someone hasn't ever used this before.<br>3:17 Here now our example includes CPM cost views. And it has a description down here. All we did here was add a description cost per mille here.<br>3:26 We added at per am in double brackets cost then cost and then a hyphen space hyphen space.

And we have input the cost, input views, and you can add more description here as well if you want.<br>3:38 And that'll be down here in this section. As we enter the cost, so if we just enter B2 and then hit the comma, notice that the Google sheets will automatically highlight the argument Learn about arguments and their role in function calls. Opens in new tab that you're in and it will also highlight down here the description of it.<br>3:58 So this says input views, this says input the cost. As you can see, these just correlate here. If we do not have this hyphen, let's see if we just have a space.<br>4:08 What happens? We will see some difference.

Hopefully we'll see. There. Okay, we don't need the space there. We just need cost, cost.<br>4:20 If we have costs there, let's see. That changes anything. And you see cost here as an example. So whatever we put in the parameter Explore the concept of parameters in Google Sheets functions. Opens in new tab it has in the example, and we have this cost here and cost input the cost.<br>4:39 Alright, so hopefully this helps you create a custom function Understand what functions are and how to use them in your spreadsheets. Opens in new tab really, really well.

I think, again, custom function Understand what functions are and how to use them in your spreadsheets. Opens in new tab I think it's just one of the most fantastic things in Apps Script Learn about Apps Script and how it enhances Google Sheets functionality. Opens in new tab because it makes it so much user friendly for people who are not necessarily going into your Apps Script Learn about Apps Script and how it enhances Google Sheets functionality. Opens in new tab and seeing what<br>4:56 was that name of that function Understand what functions are and how to use them in your spreadsheets. Opens in new tab again. Do I have to remember? No, you just have to start typing and now all of this information is now for.<br>5:04 Seeing for the user or shown for the user. It's so fantastic.

There's much more about it in custom functions Discover how to create and use custom functions in Google Sheets. Opens in new tab in Google Sheets Help, which I might go over a couple in a couple of these sections in more videos.<br>5:15 Bye.</div>