What you're after is a better method of debugging your errors. ScreenUpdating
property of the Application is not what you want :)
Instead, set a breakpoint in your code using F9, at or before where you suspect the error is happening. If necessary, you can put this on your first line of code (if you literally have no idea where the error happens).
Here is a breakpoint, it's the red/maroon highlighted line:
Then, using the F8 key, you can step through the code line by line.
You can add as many breakpoints as you want. Pressing F5 will execute the code only up to the next breakpoint, then you would have to F8 or F5 to resume execution.
Some additional things to help you debug
Use the Locals window.
This shows you the vairables in scope, and you can click on them to view their properties/etc. As you can see, I have a shitload of variables in a fairly complicated application. I've found the immeidates window is very helpful for Object
variables and arrays. Here is what it looks like when I expand an array variable, so that I can see all its contents:
Use the Immediate window to query variables or execute statements outside of your code, this is equivalent to Debug.Print
statements. For example, let's check to see if the value of some variable is "9", you can:
?someVar = 9
and then press enter. It will show you True or False. You could query the value directly by ?someVar
and it would print the value.
In this screenshot, I am checking the value of a boolean, and it shows me that the value is False
. I could also verify this in the Locals window.
F8
in the debugger. You can literally go through it line by line this way. Cheers. – David ZemensLocals
window or add watches so that you can monitor the values held by your variables, and theImmediate
window can also help debug. – David Zemens