Reputation: 2701
While working with Excel, I have many times faced the problem with Screen Refreshing.
Most of the time, in order to speed up VBA, programmers will use Application.ScreenUpdating = False
. This will temporarily (until cancelled) stop screen refreshing. Unfortunately, there are cases, such as implementing progress bar, when you actually want to show some progress to the user. The problem is that the already mentioned command has stopped all screen refreshing.
This means, that even if on your UserForm
you call a command to change a label (e.g. which would state Processing transaction 15 of 250) but you simply cannot get it to display.
What some people do in this case, is to temporarily enable ScreenUpdating
, and right away disable it. This procedure is unfortunately unreliable, as if you have some difficult procedure (inserting complex formulas into cells) you are not guaranteed all the time that it will also refresh the label itself. Also the problem with this approach is, that you repaint not only your desired UserForm
, but also Worksheet
as well, and therefore this 'refresh' slows down your code quite a bit.
How can you refresh UserForm
without refreshing the whole Excel?
Upvotes: 1
Views: 6212
Reputation: 2701
The answer is simple.
Let's say that your userform is named frm_Main
, so then in your VBA code you can simply call frm_Main.Repaint
.
Simple as that!
Upvotes: 2