Generate Short Random Codes or IDs

Learn how to generate short random codes or IDs using Google Sheets and Apps Script, ensuring uniqueness by checking for duplicates. This tutorial covers creating custom menus and functions to streamline the process.

You want a short ID code, something like a few letters, maybe a number , maybe I'll show you how this, what I'm about to show you is gonna be very useful for any amount of characters, any num amount of numbers.

Exactly a duplicate unless we check. So we're gonna be checking in this video, so let's name our project. Generate short code.

two numbers, three numbers, whatever. It's gonna be a randomized thing. And then we're gonna come back up here, or we can put it anywhere really.

Create code. And we're just gonna call create code. So we don't need our function up here.

a four loop be I equals zero. We'll start out with, with and I is less than the count, and that means that it's just gonna go until we have this many numbers.

We can put those here. Or we, we don't want any zeros. We can take delete zeros. Now you can edit this and customize this characters for whatever characters you want.

Maybe we do want letters and numbers in the same thing. It's okay. All right. Let's create our duplicate checker and actually generate a code here.

Do get row so that we know, we know what row we're on. Let's get our let's code of characters. Which is generate characters and we want three characters.

we say, okay, make the code, and then if it includes a code, keep trying. Do it again. If it doesn't include the code, if this is false, we're done.

Now, what's really cool is this end result. We could do return code and then use this create code in say, a pending.

And the code has to be plus actually, no, no. Plus just M1. And our code up here generate characters. Maybe it's only two.

even use this, plus use AI to actually generate code for you and know how to read it and know how to edit it all the time.