Hey guys, welcome back. So in this video, we're going to discuss the go to statement and creating labels using the go to statements. And creating labels enables us to jump from one part of the code or from one point of the code to another point and bypass some code. So let's see how we can do that. Basically, you right go to, and then let's say you want to jump to a certain point, okay? You're gonna call this point something, so I'm gonna call it my ending, for example.
And then you need to actually write the name of the point somewhere with a colon. So what this is going to do is that whenever we execute our code, and it's going to execute this line, it's actually going to jump from this line to this line here. And it's going to bypass the code here. So it's going to bypass this part of the code. So let's start executing that code step by step here. So when we execute that line you can see here it's gonna jump actually an execute anything after the my ending label.
So we can actually put a message box for example on the My ending. So message box, we have skipped, skipped some code. So if we execute the code step by step, again, you can see here it's going to jump and execute any lines of code after the my ending which is going to execute this message box. And so, okay, so this is what it does. And you can actually do the reverse so you can like jump upwards, so go to my beginning, for example, and then you put a my beginning somewhere here, and then with a colon. So actually, when we execute this code, we're gonna end up in a closed loop, okay?
We've skipped some code, go to my beginning, skip some code, go to my beginning, okay? And we're never going to reach the end sub statement, right? Because whenever we execute the code, you go to my ending, execute the message box. And then this statement here makes us go upwards goes and start to code again. And then we execute the code again and messagebox, and so on and so forth. And we are now in a closed loop and the macro is never going to end.
So if we execute this macro, it's never gonna end basically. So let's say I'm just introducing you to a concept, which is creating labels and using the go to statements because we're going to use it in our examples on the course. I'm going to use it a lot, and it's going to be useful especially in our handling. Okay, so let's say it goes to a go to statement and creating labels. Thank you very much for watching this video and I'll see you on the next one.