Progress bar freeze while running code

  • Thread starter Thread starter rezafloyd
  • Start date Start date
R

rezafloyd

Dear experts,
I have a user form in my VBA code which contains a label and progress
bar to show the user the percent of calculations completion (label
shows the percent of completion).
When the number of calculations is too high, sometimes the label and
progress bar seems to freeze but the calculations actually continues
and I get the right results. This problem doesn't happen always (even
for same calculations).
Any help?
Best regards,
Reza
 
Try adding the line,

UserForm1.Repaint

after each iteration/calculation - probably best in a loop.
 
JakeyC said:
Try adding the line,

UserForm1.Repaint

after each iteration/calculation - probably best in a loop.

Dear JakeyC,
Thank you for reply.
I've already done it, but no use.
Regards,
reza
 
Dear JakeyC,
Could you please kindly give me more information about DoEvents and
how can I use it?
I saw the Excel help file but it wasn't clear for me.
Thanks
Reza
 
Basically, DoEvents can be called as a function, but used as below, it
allows the operating system to process anything that may be queued up -
especially during a long-running macro where CPU usage is constantly at
or near 100%.

Use it as in

For i = 1 to 100

<Lots of calculations>

DoEvents

Next i


It's a longshot but worth a try.
 
Back
Top