Hey guys, welcome back. So in this video, we're going to see how we can call one procedure from another. So how to run a macro from another macro. And we're going to see the scope of the variables and how their value actually becomes empty once you exit the procedure that they have been declared in. And on the next lecture, we're going to see how to declare public variables. So actually, I've got a procedure here called calling procedure and within that colon procedure, we're going to call another procedure that I've called cold procedure that is actually below here.
So the procedure below will be called by the procedure at the top. So if I go through the procedure at the top, if I go through the macro at the top by pressing f8 on my keyboard, so I'm going to step in to the macro going into it step by step. And as you can see here, I'm now on the line that says cold cold procedure. So when I execute that line, we're going to go to the court procedure. So this is actually how we can call a procedure from Another procedure just write coal and the name of the procedure that you want to call. And as I'm stepping through, I'm actually here on the step that will set the value of a variable called var two in the coop procedure to 125.1.
I'm actually going to set up a watch window here. So I'm going to right click, click on Add watch. And then I'm gonna create a watch window for var two. And our watch window basically enables you to keep an eye on the value of your variable as you're stepping through your procedure and the context of it is going to be in cold procedure. Because this variable is limited, the scope of it is limited to only this procedure. So I'm going to press ok here.
And now when I execute this step, you'll see here this value is currently 125.1. So this watch window here enables me to keep an eye on the value of my variable as I'm stepping through the procedure. Now when I execute the step, that is called So you can see here that the value is now out of context. And actually my variable has become empty. So if I write in my immediate window here a question mark and then var to to ask for the value of var two, I'm not going to get a value is it going to be an empty value because the value of the variable has been cleared once the procedure has run its course. So as you can see here on the court procedure, after I finish it, the value of this variable var two is going to be cleared from system memory.
And it's not going to contain any value. So this is something that you need to bear in mind that when you declare a variable inside a procedure, once your procedure finishes running, the value of the variable is going to be cleared from system memory is not going to have any value. And if I just execute the N sub here, just to finish everything, so that's it. So you need to bear that in mind when you declare a variable inside a macro and the macro has run its course the value of the variable is going to be clear from system memory. So how Do we create some sort of a public variable and something that can retain its value throughout the module or throughout the workbook? We're going to see that on the next video.
So thanks guys for watching. I'll see you on the next one.