How to Make Hangman Game In Google Sheets

About this Tutorial

Learn to create a fun game called Hangman in Google Sheets with Better Sheets. Watch the video to challenge yourself and see how it works. What other games can you make inside of Google Sheets? Create a game of hangman inside Google Sheets. Showcases a few Google Sheet formulas like SEARCH()

Video Transcript

 Hello, welcome. This is a fun game called Hangman, a very classic game, and I've created it in Google Sheets. This video we're gonna cover the very last part. I will also go over how I built this piece by piece as best I can. But we're gonna first, well first I challenge you. You can pause this video right now.

Actually, I'll show you how it works up until now. , then pause the video and then build it yourself if you feel up to the challenge. And if you do build it yourself. Come back and find out how I did it. Cuz I don't think the way that I did it is the only way, nor is it the best way. It's just the way that I did it.

And I think you could potentially do this yourself if you have watched a bunch of the videos on Google Sheets have better sheets. If you are not yet a better Sheets member, if you're watching this then you're probably watching it on YouTube. So go ahead, become a Better Sheets member to learn how to design better Google Sheets, how to improve your Google Sheets experience.

How to make just working in Google Sheets a better experience. This is also fun. If you are a better Sheets member, you get these sheets completely. You can copy them completely and you get Over well over a hundred videos now available to better Sheets members. So again, in this video I'm gonna show you first how to play the game, but then you'll see that there's something missing.

We have, we already have our hangman here. We need to make 'em disappear and then show up as we make wrong guesses. So first, here's We have a word. We have a word already. It's a 10. 10.  Letter word, maybe ish. We have to guess, and as we go down, we can make our guesses here. And if you notice here this is saying how many wrong guesses we have left.

All of these are just all the alphabet. So A through Z. We can try to guess. B. No, we only have seven wrong guesses. And as we guess our correct one looks, we have the C filled in. . Okay, let's start D. Okay, we have a D. We have a c, e. Okay. We have an E, F. Nope. So we still have six guesses left. How about a G?

Okay, we have two Gs and E. A D and a C. Okay. E, F, G, H. Okay. We have, that was wrong. Five wrong guesses and. What's missing here is this should be building as we're missing these. So we're gonna build that soon enough. H I? Nope. J? Nope. K. Oh two Wrong guesses. Left L. Okay. That was one. L M. Oh, we have one more.

 Wrong. Guess left. So if we get this down to zero, like again, this should be almost 100% complete. So this would be probably like, we'll probably build this in a few minutes. Just the last foot is not here as one guess is wrong. Well let me just fill it in for you cuz I filled this in. So as you can imagine, it's actually two words.

I got you all along. It's Google Docs is the, , but how did we do this? How did we make this count down? How are we gonna make this disappear and reappear? How do we make all of this? I will walk you through it piece by piece right now. Again, pause the video. Now is your last chance. Pause the video, make your own hangman game in a Google sheet.

Comment below with a link. Share it. If you do make one, if you don't make one and you just watch the rest of this video, then go ahead. Use the tips and tricks you've learned through this video and make your own game. Alright, so here is how we made it up until this point, and then the third part of this video.

So the first part of the video is just to show you how it works. No. To show you that it's working. The second part of the video is to show you how I made what I made up until this. . And then the third part of the video is we're gonna make this hang man disappear and then reappear as these numbers go down.

So you probably already know how this might work or you don't, I don't know. So, couple things. One, these are basic dropdown menus that I used a data validation for. Okay. Can you look at that Data validation? I said a list from a.  and this list from the range is all of column A and alpha. So I just name this sheet Alpha, let's go look at it.

And it consists of three columns. The first column is just A through Z. That's it. So just to select the letter here is a dropdown menu and. To be honest, this is probably the simplest part of the whole thing. Just make a dropped down menu from A to Z. You could, you could have done this with how can else, can you do this?

Imagine maybe you did this from like list, from list of items and then list there some other way. You know, Ken, I thought this would be easier just to drop down menu with data validation. You know, nothing's gonna go wrong here.  Now what I did. Okay. And then I guess the other thing is, how do you get a word here, right?

Well, I didn't wanna make the word available to like write, like, just write it here. Right? I wanted the word to appear. So what I did is I created a third tab and I wrote the word here and I numbered the letters one through 10. I don't know why I did that. I don't think I needed to do. I think I did that just for when I was building it.

Like I knew I would have letters one through 10, . Maybe I was supposed to do it here. But yeah, you can write any word here. Let's do log jam. Lemme just write in all caps and then we can get rid of that docs. And what's going on over here is that we know the word length is just a lens of join. So I've joined all over those lit letter.

Together from this word I said a three to J three. I said, join that together with nothing. So actually I think you can even do that. Yeah, you're gonna even save yourself a couple keystrokes. You don't even have to do a empty quotes. You can just do empty everything. And it's gonna join all of those letters together.

And then Len is length. So I'm literally saying what is the length of this sort of array or string.  Which is, you can actually see the word log gym up here cuz this is joining those together. So there's a little bit of a hint here,  of what is the answer? Somebody goes in here, but then oops, we don't want to, let's do that.

Okay. So next thing we did is, let's see how we reveal these numbers or letters.  What we're doing. Hmm. How should I express this? So if there's an error, we're gonna have a nothing. So if you've seen other videos, what I do is I, I put a error if error around something that I know if it's an error, I don't wanna show anything and I'll do if error.

So is error.

And what this does is it says there's any error to show literally nothing. , I'm going to delete that right now. And now is if, is saying, well, if we search for the word A three, which is the first letter, see it's an L and we search for it. Enjoying, we're joining these two columns together with see again, nothing.

And so it's just giving us a saying, a string. Okay. So if we, let me get out of this. If we put a BBC here, what this search is, what this join becomes, let me show you what that join becomes is it's abc. See, so what we're doing is we're joining all of these together and we're just asking. Is the letter that it's supposed to be there, that first letter?

Is that in this string at all? Okay. We use the search. Okay. And we're searching for what is it that we're searching for? We are searching for this letter L. Okay. And we're saying search for Word 83 and we're gonna search all of here and it's, it's gonna get an error.  because the search brings up in search valuation, cannot find L within A, B, C.

So if we have not guessed it here, then it'll be, you know, an error. Right? So let's see here.

That's why we wanna put that if error around it, right? But.  because we're gonna get an error if it didn't find it, and we just want it to do literally nothing. Okay. But if we did find it, well, what do we wanna do? We want that letter to show up. So we're gonna write around this search before we put the if error on, we're gonna say, if this search is above zero, meaning if this number is a number one, because, cause when it finds the, the word or.

in here. It's gonna give us the number of where it is. That's how search works. Search says, give us the place in which this letter is in, or whatever this string is, is in this string. And here you'll see. Let's do this one. I'll show you here. A, it says A because it found it here. Okay. Searching for A in all of this and this.

Let's go here. Lemme do it right here for you. And it's saying one, why is it saying one? Why is it searching for A and in this string and giving one? Because it's this string is A, B, C, and this a letter is the first letter here. It's in the first position. If this was B, if we were looking for B, which we are not, but let's just put a B there.

If we're looking for B, it's in the second and see, this number is two. So this is always gonna be over zero if we actually do find it. Okay? So then around the search, we're gonna put an if, if it's above zero, well, what do we want to do? If it's true, if it actually is above zero, we want it. We want the word we want, we want the letter, we want a three.

And if not, We want nothing. We, we want a a com zero. And we're, and actually if not, if it doesn't exist, it's gonna give us an error. So we put an if error around here and now it's blank. But if we guess an L there, it's gonna show up L. So really what's going on is all of these are error errors here except for this B.

We can change that back to an A. , right? Everything is an error except for the ones it found. So they're all just showing nothing and they're all hidden there. Okay, so how do we guess how many wrong guesses. Well, this was actually a little difficult too. If it's a wrong guess, it means it's in this column or one of these columns, right?

But it's not.  and there might be multiple, right? There might be multiple letters, like if there's Google, right? If we're looking for, let's do Google, right? There's two O's, two G's, and so we can't really just get the difference, right? We can't just say, you know, there's three guesses, three correct answers here, and.

five here. So, oh, did we miss only two? No, we missed three because the C, so the way that I figured this out is, let's go into this alpha. So there's, there's two statuses for each of these letters. One is it's found, which means that we use this search again when we're searching for this letter in and we're joining.

Here again, I added these quotes. We don't need those. I added this joint, so I say search for this letter in here, and I say, if you can find it, then it's found. So we just want a one here. Look, the G is here. The L is there, and it's a one. And I use the same theory here again. So if it actually finds it, we just want a number one.

If it's not found, it's gonna be an error. So we error out, we can get nothing. Okay, so I actually put this one because. . The problem is that if, if it did find the letter, but the letter was like the third, fourth, fifth, sixth letter, this number, it's gonna give us back when, when it does search, it's gonna be a 3, 4, 5.

But we only wanna know if it's fine. We found we only need a zero or a one zero if it's not found, and a one if it's found. So I use this if to say one, if it's found. So if, if that number is above zero, just give me a. . Don't gimme any other number. Don't give me the number of the search. Don't give the number you found, but just if it's above zero, give me the number one.

Okay. And a wrong guess is very similar too. I said Alright, this is a little different, . Okay, this is a little difficult to say. So at its core here, basically the idea is we needed to say, if we find it and we guessed it, then it's actually. , but if we guessed it and didn't find it, it has to be one. So, okay, this is a little complicated.

What did I do here? I minused this number, so I said, if, if it's a wrong guess, then minus this number, which if it's not found, it'll be a zero. If it's found it's one. So really, all of these are, hey, we found them in this, these two column. , we found them. So give me a one and then, oh, we went, I went into the wrong one.

So give me a one here. If you find it in these two columns. Okay. But then minus whatever is in this column. So if it's found, it'll be one. If it's not found, it'll be zero. So this will either be one in zero or zero in one. Right? So it's either a wrong guess or it's a right guess. Right? So,  as we go through, what we can do here is say, well, this is nine, you get nine guesses, and you subtract the sum  of whatever is in the C column.

So however many wrong guesses you have, they'll all be one. They will all be one. And we do nine minus one to get nine guesses. It just figured nine, you get nine wrong guesses. I also played a, I just found a couple of hangman games online and I fi figured out that they have nine wrong guess. , and then you fill in the hangman and you're done.

So that's how I get that number out. You can change that number by just changing this number here. It's nine minus the sum of wrong guesses. Okay. Whew. That was a little tough, but now that is everything that's, we have guesses here. We have our results here. Word length here. Never changes except if we change this word.

Right. That is the length. This is the number of guesses we have left. So it's nine minus however many wrong guesses we have. We can delete that. And now what we wanna do is we wanna show, we want to have this hang man guy show up nine times. If it's the ninth time, like his leg here, we're done, we're over with.

So we'll have zero wrong guesses here and we'll have you lose. But if we have all of the letters here and it matches here, then we wanna have a win. Okay? So that's actually easy. We should actually have a, if if Lynn here equals this, then we want you win. But if it's false, right? We want nothing.

Nope. This is not right. Length of F. Oh, I see why. This is probably not length. This is probably count all. Nope. F two to O. That should be, let's see. Count. Hmm. That's interesting. . Why is that counting as six? Hmm. Did I get that correct? Oh two Hmm. Because in in this state we wanted to Oh, cuz it's eight.

False. That's alright. Let's put it on the wrong side. Okay. So that was Kurt. You win and come there. So now if we guess it correctly, what was it? Google. And boom, you win. Let's make this a little bit bigger. We want that nice and big and we don't want it there. We want Ready? Ready. We, we want that to be. Woo.

You win.  whenever that happens. Okay. That, that confetti is actually loom. That's not Google sheets. Don't worry, I'm not gonna show you how to make confetti in Google Sheets, but we won that peeling right. You win. All right, let's make that a little bit of a color green. Ooh, that's terrible. Pink's fine. You win.

And then Right. That will disappear if we haven't won. Okay. , but we want also loss. We want, if this is zero, you have the wrong zero wrong guesses left. We want that to be zero here. So let me say if this is equal to zero, and if that's true or if it's false, it'll be this. And if it's true, it will be.

You lose. Ooh. Oh wait, I did that again. . Okay, wait. We want this. Oh, I see one. Think it's this. There we go. Oh, we have an error formula par error. I definitely did that wrong. Okay, we'll figure this out. Right? We'll figure this out together. If J 12 equals zero, which it does not now. Oh, that's why. It is not this,

which that's, there we go. I think we just needed to switch that around again, and now we have nothing, right? Which is correct. Right now we have. All of our word here to fill out. We have nine wrong guesses left. Now we put in the guesses. Oh, did that one. H I, let's put in the the W. There we go. You lose because we have zero wrong guesses.

Left. Done. Ooh. Okay. That is correct. So we now have a un, we have a win. Yes. Okay. What else do we need? We need to get rid of this guy so he only shows up as our wrong guesses. Show up. Right. Okay. An easy way to do this. Mm, rather a simple way that is a little harder, like a little complicated is each one of these is e It can do an if, if J 12 is great, no less than nine.

Because we want this to show up first. If it's less than nine, which is false, then we have an L here. We want that and that. Okay, so this is only gonna show up if this is less than nine. So right, we go here, put an A boom that shows up and we can do this for each one of them that we wanna show up under nine under.

we can do that again and again. So let's have this whole thing show up. I think that was supposed to be an i . Depends on how you want to do this. All right, so we want that to show up. We want that to show up. We want this whole pipe shop. So what we could do as well, Is just lock this number in with a there, there, there, and just whoop.

We want to change that to an I. Okay? We want that whole thing. So we want one, two, no, 3, 4, 5. Wait, what do we want? We want 9, 8, 7, 6, 5, 4, 3, 2, 1. Okay, so we want the entire thing to show. Okay. Let's do this. This is gonna be a hyphen.  and we go here. So this will only show up when it's eight, right? So if it's nine, it's not showing up.

Let's keep that up. And now we want, this is a pipe, but we only want it under eight, right? Under eight. Eight. So let's do that pipe there. And now we need another one. Another. So now abs, we have two wrong guess.  and now we have all of that. Let's delete that. Great. And this is how I would do it, you know, just a very simple way to do this is now we want it to be under seven.

Oh, we want this to be on under six. Nope, this is gonna be five actually. , I'll show you why. Well, let's do this first. This will be under six, so we need this first, then the arms. So 6, 5, 4. Oh, that's supposed to be a four. Sometimes we get a little tedious here, but it's fine. It's fine. This'll be. Oops.

Okay. Where was that? 4, 3, 3, 3, 2, 1. Yeah, so in a, and this will be two, this leg. And then the last leg will, the last leg of the journey. Oh, very funny. Is under one, right? So now as you see this, right when we start, we have six letters to guests. We have a hangman that's gonna show up here. And let's say we guessed some all, oh, all wrong.

Oh, I think, oh, that was a . W X, Y, Z. What is Oh, that, that's interesting is, yeah. The way that I did it is, so if you guess another letter, it doesn't penalize you. That's good. It's good. Built in safety what is it? D you lose and we have the entire hangman here. We can actually also, let's give him. . A let's do that.

Oh, I think we did something weird here. Oh, it's because it was white. Ah, we want a nice gray border. Let's make it a little ding thicker. Oh, we don't want that. . Want that board? There we go. So that'll show us our hangman. We have a you lose situation. What about the you win if we do. Let's do you win. Yay.

You got it. So we have now completed our hangman game. We have our word that we can set here if we wanna set the word and then have it show up here. So the person playing the game won't know what it is. They will know how many leg letters it is. They will have nine guesses or wrong guesses to attempt.

I figured 16. There's 26 letters. I think I did that math correctly. I think you guess every letter and then if you get all of 'em, you might have to add a 17. I can't remember. But also, you're probably not going to guess W X Y or Z or Q or, yeah, so hopefully you had fun. Playing the Hangman game and maybe making it, if you have made it and you have a different solution on how to make the Hangman game, make sure to comment if you I'm sure you didn't do exactly what I did, so maybe you learned a little bit of something about how to do use search.

Maybe in your solution you use the find and maybe you use concatenate here. Totally fine. . There's other ways I can imagine doing this. I think this was just the way I figured out today how to do this. So I would love to hear or see or watch your solutions if you have a different solution, if you have a different way of guessing, maybe you've figured out a way to limit the number of letters here as you guess them, maybe you can't guess again, the letter.

That would be really cool if you have that again, comment down below how you did that. Maybe you have a different win or lose state. Maybe you use conditional formatting and change the whole thing to black and it says you lose or you win. Maybe you did find a way to make confetti in Google Sheets. Thank you for watching.

Have a great day and enjoy your game. Bye.