Turn off screen updating in excel
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.Status Bar = Format(fraction Done, "0%") & "done..." ' or, alternatively: ' status Range.value = Format(fraction Done, "0%") & "done..." ' Some code.......Next i Sub Progress Meter() Dim boo Status Bar State As Boolean Dim i Max As Integer Dim i As Integer i Max = 10000 Application.A User Form will not be refreshed in some cases, because Do Events will fire the events; however, Repaint will update the User Form and the user will see the changes on the screen even when another event immediately follows the previous event.In the User Form code it is as simple as: This is not directly answering your question at all, but simply providing an alternative.
But the screen doesn't refresh, or stops refreshing at some point (e.g. The task eventually completes but the progress bar is useless. For i=1 to imax ' imax is usually 30 or so fraction Done=cdbl(i)/cdbl(imax) Application.I've found in the many long Excel calculations most of the time waiting is having Excel update values on the screen.If this is the case, you could insert the following code at the front of your sub: I've found that this often speeds up whatever code I'm working with so much that having to alert the user to the progress is unnecessary.You might encounter an issue with Do Events if you are using event triggers in your form.For instance, any keys pressed while a function is running will be sent by Do Events The keyboard input will be processed before the screen is updated, so if you are changing cells on a spreadsheet by holding down one of the arrow keys on the keyboard, then the cell change event will keep firing before the main function finishes.
It's just an idea for you to try, and its effectiveness is pretty dependent on your sheet and calculations.