Hey there stranger!
Sign up to get access.
5 Ways to Create Coupon Codes | Create UUIDs
About this Tutorial
00:08 You're going to notice one big thing in this is that as the level of difficulty goes up into scripting, the code on the, what we do is actually much, much simpler, but we're going to start at number one.
00:21 We can copy and paste codes from the web. This is probably how you're doing it now. Um, we're going to go to voucher five.com.
00:28 We can go to generator somewhere up here. I think we're going to just go to, I think it's literally slash generator.
00:38 We can type in, we want a hundred codes. We want single code lengthening to be six. We can generate. And there we go.
00:47 We can copy all of these bam. That is so simple, right? We have coupon codes we can copy and paste into here.
00:57 Awesome. We can get probably as many as we want thousands 100, but as you noticed, we got a copy and paste.
01:04 We got to do this, uh, sort of non-program at CLI uh, we have no, uh, we can't fix this. We have eyes and ELLs that are going to get mixed up zeros and owes.
01:18 Um, we want a little more granular, uh, control. So what I did is I went on and looked at, what do you get when you search for this kind of thing, you want to create a coupon code within Google sheets.
01:35 How do you do that? And stack exchange had some answers. And these next two are the answers to that. Um, we have this, this is a formula we can create inside of Google sheets.
01:46 Uh, we can just add a equal sign at the beginning of this, and we get a two character, um, code.
01:54 Now we want to create coupon codes because we are using this. I use this actually once to add onto, uh, my products onto AppSumo created 5,000 coupon codes.
02:07 We need uniques, right? And we don't need two letter coupon codes. We need something like a six letter coupon code.
02:12 So we can take this whole, uh, formula we can do equals concatenate. I never remember how to spell that. Put the first string comma, second, third.
02:23 And now we have a six string thing and we can pretty much let's copy this. We can create one code, a thousand codes.
02:34 We can go to the bottom. We can add 10,000 lines. We want to delete probably actually some of these columns let's delete some columns.
02:43 Let's delete all the columns except for one. There we go. So we have this code. We can go to the bottom.
02:54 We can copy and paste it. And now we have 11,000 coupon codes that was easy. Right? We use this crazy formula.
03:01 Let me break down this formula a little bit for you. Um, we're going to go back up here. Let's figure this out because this is going to empower us later on once we know exactly what's going on here.
03:13 So the choose is pretty simple. It's just saying, choose one of the next few options. We finished it, right? That let's do that first.
03:20 You can just say, choose, and it's giving us an index. So we're going to say one. We're going to choose between a, in the first index and B in the second index.
03:28 And if we put in this one, we get a, if we put in two, we can beat. See how easy that is.
03:39 Now we're going to add in ran between because we don't want to have to type in the number of one or two.
03:46 So we're going to replace this one with a ran between a ran between the same one choice, anything in between these two integers and then the second choice.
03:54 So we can actually have like three here and add a C, but that's pretty crazy, right? We're going to copy paste this down.
04:03 We can have a random letter. This might help you in other ways, but not for a coupon code. We, we need more than a, B and C, and we're not going to sit here and we're not going to do D oh my God.
04:14 We're not going to do cop a comma E we're not going to do that. Nope, Nope, Nope, Nope, Nope. We are going to do this, actually this character, we're going to add a few other things we're going to do equals character now characters fund, because there is a table of numbers and you can get any character you want from it.
04:35 So if we 2 65, that is a, we don't have to type in the letter a we can do type. We can do character 65.
04:42 We can also do character 66. Can you guess what it is? It's B can you guess what? Let's see. What 67, can you guess what it is?
04:50 It's C let's do 69 that's E and it goes all the way up. And this is actually capital. So it goes up to 90 is a capital Z lowercase numbers are letters are 97 is lowercase a and 1 22 is lowercase Z.
05:13 So do you see what we're doing here? We have, we can take a randomly generated number, flip it, turn it into a letter.
05:23 And that's what we do with this. We do Rand between, and we do a 65 comma and 90 is going to give us a random character, uh, uppercase.
05:37 And so we can do that all through here. Look at that. That's all a bunch of random letters. We can then string this along to say, uh, character.
05:49 Uh, no, sorry. Choose random between. We're just going to copy once above between one two, and either give us a uppercase character, character 65 through 90 or comma change this 97 to 1 22.
06:13 Now this is going to give us a random uppercase or lowercase number that cool. Now we can take this. And also we can do a concat Ken captain, Nate.
06:26 We can string this along. Whoops. That's a D and create, think that was six. That was seven. We can create a seven digit, uh, code that way.
06:42 Right? We can also do what we did here. And this is the answer on stack exchange, which gives us an an, and it gives us two at a time, but we can also just take one at a time and string it along and say, how many do we want?
06:56 Do we want eight characters, 10 characters, 11 characters. We got more control over it. A little bit more control over it this way.
07:02 All right, let's go onto the next one. Uh, possibility. So there's this deep decimal two hex X number. And we're going to use a Rand between, this is a crazy, uh, answer.
07:15 This was an answer again. I didn't make this up. This was online. You can find this. If you sharpen, oh, I'm trying to create coupon codes.
07:21 This might be one of the answers you get. And it is nuts. I don't know how anyone figured this one out, but there are some smart people out there.
07:30 This is decimal to hex formula, and it's using the same Rand between we used in the last one, but it's a zero to this crazy big number for how many, this is 4 billion, 4 billion, 294, 960 7,295.
07:49 Whoa, this is not. And then it has an eight here to give us a, what is this? An in decimal to hex.
07:57 This is eight significant digits. Um, we only have eight here. Uh, if we do let's move that to five, it must be at least eight.
08:10 If we do 10, we get zeros at the beginning. So not much control, but this is a crazy difficult answer to give of this decimal to hex ran between.
08:21 I don't know how to mess with this much, but if you definitely need only an eight character number or code, there you go.
08:31 You've got a pretty crazy answer, but let's go deeper. I think we can create a much better version of this, but by using mid, okay, uh, we already did this.
08:47 So I'm gonna start from the beginning. We have a little bit of an idea of what we need. We need equals.
08:55 We need a, B, C, D E F a, and we want to not have capital owes zeros, ones, lowercase L's and capital eyes.
09:07 We don't want those because they're really hard to read for users. We want to create a coupon code. That's really easy to read.
09:13 We won't mess up anything up. If someone has to type it in. So we have this list of what we need.
09:22 I already typed it out here. And in order to know, use mid, we need to know the length of this character.
09:29 So we have this list and we also have some 2, 3, 4, 5, 6, 7, 8, 9. So how long is this? Let's do that. Let's find out Lem D six.
09:43 It is 54 characters. So we have 54 characters. Now, if you're piecing it together, if you're a step ahead of me right now, you'll figure it out.
09:50 You'll say equals Rand between will give us from one to 54 random number, right? And we can possibly connect this number to one of the indexes of this, uh, list.
10:07 How do we do that? We're going to use mid, okay. So I'm going to copy this. I'm going to combine all this.
10:12 So equals M I D what is the string? We have our string. Should we need to put it in quotes?
10:19 Okay. Now, starting at, what are we starting at? We're going to start at Rand between one to 54, and then we need one letter from this or one thing from this list.
10:32 And there we go. We have now a random uppercase or lowercase letter. We have either also a potentially a number, but we have it in a list that we have full control over.
10:44 We can say out of this list, what do we want to put in? Take out. We can take out, uh, on the lowercase, right?
10:50 If we put, if we take out all the lowercase first, we have to do equals Len. Let's find out how many there's 32.
10:59 Okay. So this is with uppercase with out lower case. Actually, this is sorry with lowercase. So we have 32. We'd copy this whole thing.
11:15 We put it here. We take out all of the lowercase letters. If we want to. And we changed the 54 to 32, and now we have upper case letters and numbers.
11:31 Now you should be ahead of me here too. How do we string this together to get six of these? We use our old friend concatenate that we don't know how to spell.
11:42 Never know how to spell. I'm going to copy this equals Kern K. There is concatenate. We're going to put this one, comma paste, another one, comma that's two.
11:53 So we have three paced career, three, we need paste. One more. We have 4, 5, 6. Now we have a six digit coupon code that we can make thousands of these, but how do we get them?
12:09 Let's duplicate this. I want to delete everything except this these codes, make sure I don't put them up here. So we have a bunch of codes.
12:21 How do we actually get them the same? Right? You notice they're all twisting and turning and everything. Let's add another 9,000 rows.
12:32 And we're just going to keep copying and pasting this formula. And we're just gonna get random, random stuff. But how do we keep it?
12:40 We're going to do shift, command down. We're just going to copy the whole entire column. And then we're going to paste.
12:48 This is going to be edit paste values only. And this gets us a hard-coded list. This will never change of 10,000 coupon codes.
12:59 Now with this, we can do lots of cool stuff. Once we have random numbers, we can create coupon codes. We can create user IDs.
13:07 We can create all sorts of things with this, these codes, right? We have unique identifiers, all sorts of great stuff.
13:15 Now, if you just want to create simple six digit coupon codes, which you have full control over, we have done that.
13:23 We have done that in a number of ways. We've used copy pasted code from the web. We've used this crazy formula with choose ran between ch character.
13:32 We did decimal to hex showed you that and mid, and this mid actually gives us much more control. It's actually much simpler.
13:41 Uh, even though it's more difficult to create, it's simpler implementation. Now the next one, the final one is probably the most, most difficult, and it is the craziest one, but it is going to be simple.
13:56 Once I walk you through this, you're going to be able to do it. I guarantee you, you can do it.
14:01 Um, it is using Google script. If you are scared of Google script, watch it continue watching this video. I'm so excited to be able to share this with you.
14:09 It is one line of Google script, and it's going to create a U U ID, which is a universally, a universal unique identifier identification.
14:19 Um, what we need to do is here's the page. We're going to do it on. This is going to be a long text.
14:27 So everything we've done so far has been a coupon code that a human can read. We even made it much better for a human to read.
14:35 Got rid of the eyes, got rid of the, oh, is this is more for like, if you really want a unique identifier within your system, you can use it for anonymizing users in your system, students projects, you can use it to tag project names.
14:50 If you want to get, like, if you have different project names, sorry, if you have the same project name, but you want to have unique identifiers for them.
14:59 Sometimes in our system, we have people's names and they are not unique. So we can really UID for unique people.
15:04 All right, let's do this extensions apps script. Alright, let it load. You usually have my function here. We're going to write or where you can go in here.
15:15 If you are brand new, you can copy what I'm doing. You can delete anything else in here. We're going to do function.
15:23 Create U U I D. We're going to put two parentheses and then two curly brackets. And inside the curly brackets, we are merely going to say you Tilly's dot.
15:40 Nope, not CRE get U U I D two parentheses. We're almost there. We have one thing left to do is we return and that is it.
15:51 So I'm going to hit command S to save. Now, how does this function work? While we go back to our sheet and we go equals, and we paste that create you, you ID that.
16:01 We said, it's going to give us this underlying red. It's going to say unknown function, but we're going to put in these parentheses and hit enter.
16:09 It's going to load. This is going to take, oh, and take a moment now the second. And here we go, we got you.
16:15 You ID that, is that it all we have to do. Oh my God. We can copy and paste this and we can let it load.
16:23 Don't take your, you're watching it in real time. I'm not pausing the video. Oh my God. We can copy paste this down.
16:29 We can go down all the way to a thousand rows and we can let it load. This might take a little, a few moments.
16:39 Yeah. It's going to take a few moments. There we go. They're loading, they're loading. And we have a thousand unique.
16:45 We can do the same thing that we did before. We can take all of these and we can copy and paste the values.
16:52 So now that Y equals create you, your ID is gone. Oh my God, this is so much fun. This is way more difficult yet.
17:00 So much simpler, but we got more stuff for you. I got a couple of things left to show you. Okay?
17:07 Okay. So there is something we can do with custom, uh, functions. And that is we can create them to make them auto complete.
17:18 What this really means is that they can become like unique, um, sorry, native. So, uh, formulas. So concat shows up here, right?
17:27 But if we do equals create you ID, it doesn't show up. How do we get it to show up here?
17:33 We have this custom function and we add this text at the beginning, and we can say here, instead of multiplies, the impact value creates a U I parameter number.
17:51 We don't need that. We can delete that whole thing. Return a unique UID command S to save. Now we go back to our sheet.
18:02 We type in equals create your ID. It's right there. Isn't this awesome. We've created a native function within our Google sheet.
18:12 Let's see what it does. Let's see what it does. It does the exact same thing. This is awesome. Now we can go back and we can even rename this.
18:25 Like once we changed that name, how do we remember the name? We can go back and, oh my God, there it is create.
18:45 So to summarize, we have copied and pasted code from the web. We have created a, we have gotten two formulas from the web as well, stack exchange.
18:56 We got this choose. We got decimal two hex one. Then we created our own formula with mid a coupon code generator ourselves.
19:08 We have more control. We have more independence over what is in each of the codes. And then we did a crazy thing, which is we went into Google script and added a <inaudible> generator, uh, in one line of code.
19:23 And we also created a, we did that. And we also created a custom function, which acts like a native formula inside our sheet.
19:32 This is crazy. I hope you enjoyed this video. Thanks for watching.
Sheet Stories / Video Notes + ADDED: Email Notifications
ChatGPT Clone in Google Sheets Part 2
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
Hold a Giveaway Raffle in a Google Sheet
Embed a Headline in a Website from Google Sheets
Capture Emails from Website Form to a Google Sheet (Without Zapier)
Quickstart Tutorial OpenAI API in Google Sheets
Create a new Spreadsheet from just a Name in a Sheet.
Bjarne Asks: Can I show the Last Time of the Last Edit in a sheet?
Email Yourself a Cell from a Google Sheet, Every Day
OpenSea Data Inside Sheets
Create an Email Campaign Stats Calculator
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
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
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.
Password Protecting Data In a Google Sheet Part 2 The Basics
Benoit Asks: How to Convert Case
Learn to Code in Google Sheets, For Programmers
Add a Checkbox to Turn on Dark Mode
Write Your First Script
Find Keywords in Any Column. Create quick search dropdown to find keywords
Basic CRM - Add a Powerful Script To Move Row Based on Status
How To Improve: 1,000 Business ideas: Business Idea Generator
Let's Make a Bookmarklet!
Troubleshooting Bitly in a Google Sheet Script
Unique Features - Design a Better Dashboard Part 2
How To Set Up Stripe Webhook to Google Sheets with Google Script
How to Edit a Macro
Sheet Stories / Video Notes + Clear 24 Hour Old Videos
Add A Timestamp to Task Lists (without Now Formula)
Make your Custom Functions Like Native Functions | Custom Function Autocomplete
Create a Changelog Between 2 Cells Custom Function | To learn Double For Loop
New Syntax for WhatChanged Formula in Google Script
How to Record Macros
2 Ways to Delete Lines Quickly (CAREFUL, it's a script!)
Deep Inside Dark Habits Google Script
How to Trigger Macros Daily
5 Ways to Create Coupon Codes | Create UUIDs
Create a Radio Button From Checkboxes Using Google Apps Script