Reputation: 562
So I have seen all the ways to hide the screen updating in excel, what I'm looking for is a data problem, so I WANT to see the screen update. Is there a way to code the screen to update during the macro slowly? I tried the following:
'//////adding screen updating to watch what's happening Application.ScreenUpdating = True Application.Wait Now + TimeValue("00:00:01") '/////
and all I got was screen flicker.
Thanks for being excellent unto me.
Upvotes: 1
Views: 237
Reputation: 53653
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.
Upvotes: 7
Reputation: 86620
The screen updating must be set only once, at the start of the code.
But the Wait
you will need to put inside your loop, or spread between your code lines.
Upvotes: 0