Hi there, this screencast is going to go over how to debug and to step through lines of your code. I've got a pretty complicated example here that calculates the exponent of a number, and this is in a file called debugging.xlsm. So, if you want to pluck this off of the course site, then you can work along with me. So, I've got this sub, got some advanced programming structures here that you haven't learned yet. Regardless, I want it to explain what happens when you debug. So, the most important thing is to have this locals window open, which is down here on the bottom. To make that open, you go up here to the View menu and you do locals window to make sure that that's open, and that's really important. This is where we see into the brains of the editor and what's going on inside of its head. So, I'm going to step through line by line. There's this debug drop-down menu up here, and you notice that there's a step into which is F8. So, I just press F8, I put my cursor inside the procedure somewhere in then I'm going to press F8. So, I press F8 and we're going through here. You notice when I just executed this x equals 2.1 line, down here in the Locals Window, you can see what the editor has for all those different values, and this is an invaluable way to look to troubleshoot and to see what's going on inside your program. So, I'm going to press F8 a couple more times and we go through, you notice that in this line here, I've got another function. So, in this sub, it's jumping out of that into another function, and then we go through that function, and it outputs, and now we can look at the value of S here. At this point in the code is equal to one, and now I press F8 again, we increment i by one and so on. So, this is how you can go through your code. I wanted to show you some other things that you can do while you're debugging. Now, let's say I'm pretty certain that my factorial function is working properly and it's a pain how it steps into here and you just have to keep pressing F8 a bunch of times. So, if I wanted to step over is what is called, when I execute this line, I want to go straight from this line to the next i line without jumping down into my factorial. While on the debug, there's a Step Over, which is shift-F8. So, when I'm back over here, I'm just going to do Shift-F8, and we step over any other procedures that are on that line like a function here. If we do go into a sub procedure like this, and I want to step out of, we can go up here to debug and you can go Step Out. You can click on that or I can do Control-Shift-F8. So, here, if I do Control-Shift-F8, I Step Out of that other procedure. Another thing I wanted to show you is, let's go back into this function. Now, maybe I just want to run to a certain line, I can put my cursor here, and I can do Debug, Run to Cursor. Alternatively, you can set your cursor and you can just do Control-F8. So, you'll learn these key combinations as you go. Now, another thing I want to show you, let's go ahead and reset this up here with that reset button. There's a couple of other interesting things you can do. One thing, if you just want to run until a certain point. So, you just want to stop when it gets somewhere, I can put a breakpoint. So, I'm going to put a breakpoint right here. You just left-click in the sidebar, and then you can run using F5 or pressing this "Run" button, and It'll just run until the code hits that breakpoint. It's basically like a stop sign. Then you can look at your code to see what's going on, and then you can debug from there, you can press F8 to do line by line. In this case, that just finishes the sub. Or, you can run again to the end of the procedure. Then to remove a breakpoint, you just do is left-click again. There's also some things that you can do. There's something known as the debug.assert function. So, you can put this inside your code, you actually have to write a line of code, and it's counter-intuitive, but, what if I wanted to debug until S becomes five? Now, it's counter-intuitive because it's going to go until this is false. So, it's going to go, and go, and go, and then as soon as this is false, meaning S is equal to or greater than five, it's going to enter into debug mode. So, if I just run from here, press that "Run" button or I'm going to press F5, see how it ran, and now, 5.3 is no longer less than five. So, this is false and then we're in debug mode. So, then you can do F5 from there. Another thing we can do, and let me delete this line, this Debug. Assert line. Another thing we can do is you add a watch. So, I'm going to go up here to the Debug Menu, I'm going to add a Watch. This is similar Debug.Assert, except you're going to break when in the example, I'm going to use this break when the value is true. So, I'm going to say I'm going to break when i equals four. So, I'm going, we're going to to run this, and as soon as i equals four, it's going to go into break mode, and then we can press F8 to debug through. So, down here in the Watch type, there's a couple of them, I'm going to do when, break when the value is true. So, when value i equals four, we're going to go into break mode. Then I'll go ahead and press "Okay." You notice that there's a Watch down here. So, now I put my cursor back into that and I run. You see that we broke when i equals four. So, we've gone until i equals four. This is just an advanced debugging technique. Then, I can press F8 to keep going. All right. I really encourage you to become familiar with these debugging techniques. They're really going to help you out especially as you get to more complicated things in VBA. Thanks for watching.