This example demonstrates how turning off screen updating can make your code run faster.The example hides every other column on Sheet1, while keeping track of the time it takes to do so.There may also be a way to execute a macro from VBA using the Do Cmd method, but I'm not familiar with doing that.Everyone I have talked to has advised me to avoid using macros when possible. Turn screen updating off to speed up your macro code.Remember to set the Screen Updating property back to True when your macro ends.The macro runs when the user clicks a button on a form.I would like the queries to be invisible while they are running, but currently the user sees 50 query windows open/close which is ugly.
You won't be able to see what the macro is doing, but it will run faster.
Display Status Bar = True ''//Make sure that the statusbar is visible For i = 1 To i Max ''// imax is usually 30 or so fraction Done = CDbl(i) / CDbl(i Max) Application.
Status Bar = Format(fraction Done, "0%") & " done..." ''// or, alternatively: ''// status Range.value = Format(fraction Done, "0%") & " done..." ''// Some code....... Display Status Bar = boo Status Bar State ''//Reset Status bar display setting Application.
As there is no command in Excel to refresh a worksheet in the way a user form can be refreshed, it is necessary to use a trick to force Excel to update the screen.
The following commands seem to do the trick: Specifically, if you are dealing with a User Form, then you might try the Repaint method.
It's just an idea for you to try, and its effectiveness is pretty dependent on your sheet and calculations.