ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Progress bar freeze while running code (https://www.excelbanter.com/excel-programming/376055-progress-bar-freeze-while-running-code.html)

rezafloyd

Progress bar freeze while running code
 
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


JakeyC

Progress bar freeze while running code
 
Try adding the line,

UserForm1.Repaint

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


rezafloyd wrote:
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



rezafloyd

Progress bar freeze while running code
 

JakeyC wrote:
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


JakeyC

Progress bar freeze while running code
 
Hmmm - have you tried DoEvents?


rezafloyd wrote:
JakeyC wrote:
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



rezafloyd

Progress bar freeze while running code
 
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

JakeyC wrote:
Hmmm - have you tried DoEvents?




JakeyC

Progress bar freeze while running code
 
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.


rezafloyd wrote:
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

JakeyC wrote:
Hmmm - have you tried DoEvents?





All times are GMT +1. The time now is 04:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com