ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Let user break out of a big computation? (https://www.excelbanter.com/excel-programming/443657-let-user-break-out-big-computation.html)

Robert Crandal[_2_]

Let user break out of a big computation?
 
I have a Userform which contains two buttons. One buttons
says "Begin" and the other button says "Cancel".

If the user presses "Begin", my macro will begin processing a
potentially long computation. Once the computation begins,
can I allow the user to press the "Cancel" button to break
out of the big computation?? Is that possible?

Additionally, is it possible to display some sort of progress
bar to display a percentage which shows how much of the
computation is complete? Would I need some sort of plug
control for this? Or can I just simply update a text label on
the form to show percentage completed??

Thank you!



Harald Staff[_2_]

Let user break out of a big computation?
 
Hi

If your code knows how much is done and how much is left, then a progress
function is easy, simple percentage calculation.
http://spreadsheetpage.com/index.php...ndicator_demo/

If you know the steps but not the time, this is a good way of visualizing
the progress:
http://www.dailydoseofexcel.com/arch...-progress-bar/

As for stopping the procedure, here is a very simple demo. All it does is
count up in the statusbar (lower left corner of Excel):

Option Explicit

Dim StopIt As Boolean

Sub BtnStartCode()
Dim m As Long, n As Long
StopIt = False
For m = 1 To 10000
DoEvents
If StopIt = True Then Exit Sub
For n = 1 To 999
Application.StatusBar = m * 1000 + n
Next
Next
End Sub

Sub BtnCancelCode()
StopIt = True
End Sub

HTH. Best wishes Harald


"Robert Crandal" wrote in message
...
I have a Userform which contains two buttons. One buttons
says "Begin" and the other button says "Cancel".

If the user presses "Begin", my macro will begin processing a
potentially long computation. Once the computation begins,
can I allow the user to press the "Cancel" button to break
out of the big computation?? Is that possible?

Additionally, is it possible to display some sort of progress
bar to display a percentage which shows how much of the
computation is complete? Would I need some sort of plug
control for this? Or can I just simply update a text label on
the form to show percentage completed??

Thank you!





All times are GMT +1. The time now is 06:12 PM.

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