Progress bar freeze while running code

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
 
J

JakeyC

Try adding the line,

UserForm1.Repaint

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

rezafloyd

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
 
R

rezafloyd

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
 
J

JakeyC

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top