Updated June 12, 2023
PART- 8 – Visual Basic Editor (VBE) – Watch – Immediate Window
Video Transcript – Visual Basic Editor (VBE) – Watch – Immediate Window
Video on Visual Basic Editor (VBE) – Watch – Immediate Window – Now let us look at other debug tools here immediate window and we have the watch window I’ll discuss the watch window 1st and I’ll on click watch window and movement I do that you can see that this actually pops up with cross sign so I may want to actually have both of them simultaneously in order to watch essentially mean that you want to track a certain variable so say for example between X and Y I may want to just track Y so for choosing this and moving it into the watch window process is that you just choose this highlighted right click and you will have this add watch ok any variable right click go to add watch and it provide you with an expression Y and there are different kind of watch type and you want to watch the expression or you want to just come out code when the value is true or probably you just want to break when the values changes probably I may not want to kind of do this 2 break when value is true, break value changes I just want to kind of look at watch the expression and I’ll click Ok so the movement I do that as you can see here this is not so visible it’s write as out of contest what this mean is that since your code has not yet run this value is out of contest at this stage no specific meaning all together so let’s start the code and the step into this and see what comes when we have the local windows and watch window simultaneously movement I step into the code as you can see here as left hand side we have X as 0 Y as 0 and Y which is under the watch screen again obviously the value is 0. Now when I run through the code on the local window all the variables get updated but on watch window only the Y variables gets to be seen so this is how you know probably you can use your locals and watch window there is one more window which is left that is the immediate window so lets click on that and see what happens immediate window is nothing but window that helps you check the value of the variable and may be want to change the value of variable you do that from this platform let say for example you know for doing that lets first run and step into the macro let me do that and if I want to check what is the value of the X which is stored of now here I need to type question marks and press Enter so the value here as off now is 0 because its start by defining X as integers by default the value is 0 let me move and now again define and ask for the value of X what this would be this comes out to be 22,000 because X was defined as 21,000 and here X was updated by another 1,000 so value changes to 22,000 so this is how you know probably you can play with immediate window say for example you want to change the value of the variable but before that let me just check what is the value of Y as 0 and let me just complete this and see what is the value of Y here it is 44 so all is here is the immediate window now let us assumed that I want to change the value of his variables say for example say for example I want to change the value of X from 22,000 to something else I guess I can do that using immediate window so the process of doing this would be that let say if you can step into the program so here you have a defined X is equal to cell 1,1. value, so here, as you can see probably, I’ll just ensure that you are able to watch the locals window so X is actually 22,000 so let me defined X as some random number so that it is clearly shown 685 so the movement I do that you can see that you know probably X is now redefined as 685 rather than 22,000 earlier if I execute this code again we will see that now X is 685 + 1000 and if I execute this code again you can note that on the left-hand side, the value actually changes to 1685 so this is how you know you can probably play with the watch window if you no answer to specific variables you can put that and see how it works across your codes. 1 very important thing which I forgot apologize for that is basically how to save this file. I wish I would have to told you earlier, but you need to click on file at the top and go as save as and if you use the traditional method as CRTL S, you will be prompted with something like this as the prompt the following feature cannot be saved in the macro free air workbook and the VB project to save the file click on no so this is what I am going to do and as you can see this is VBA project.xls and I want to actually enable macros in that so I may have to save this as a file called excel macro enable work book ok so you must save this file in this format in order to ensure that Macros are fully functional VBA project.xls M is all this macro files all about so I’ll do that, and I’ll save it this is how you can actually save your excel files which are macro enable files.