ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ProgressBar Out of Sync (https://www.excelbanter.com/excel-programming/287684-progressbar-out-sync.html)

RDallas

ProgressBar Out of Sync
 
Hope you can help, I have created a UserForm with multiple
CommandButtons, each CommandButton runs a lengthy Macro.
The Code for the Macro is running inside a loop that
updates a ProgressBar. I have this process running perfectly.
After you click the CommandButton, the Macro is in perfect
sync with the completion of the ProgressBar reaching 100%,
except that when the Userform that displays the ProgressBar
is instructed to unload, it unloads leaving a white area
where the UserForm was. The white area doesn't completely
disappear until the worksheet updates all of the changes,
about 12 seconds.
How can I make the UserForm remain displayed with the 100%
finished ProgressBar while the worksheet finishes it's 12
seconds of updating?

Rocky McKinley

ProgressBar Out of Sync
 
You could try
Application.Calculate
then unload progressbar

Or ...

Adapt the following code, of course the wait one second would be unnecessary
and you would have to calculate "i" yourself which you probably already do
anyway. I can't take credit for this code as one of the Gurus had it on his
site and gave credit again to someone else. Good Luck :)

Sub ProgressBarSimpleDemo()
Dim sb As clsProgressBar, i As Long
Set sb = New clsProgressBar ' create a new progress bar
sb.Show "Please wait", vbNullString, 0 ' display the progress bar
For i = 0 To 100 Step 20
sb.PercentComplete = i ' update the progress bar
WaitSeconds 1
Next i
Set sb = Nothing ' remove the progress bar
End Sub

Private Sub WaitSeconds(waitTime As Integer)
Application.Wait (Now + TimeValue("00:00:" & Format(waitTime, "00")))
End Sub


--
Regards,
Rocky McKinley


"RDallas" wrote in message
...
Hope you can help, I have created a UserForm with multiple
CommandButtons, each CommandButton runs a lengthy Macro.
The Code for the Macro is running inside a loop that
updates a ProgressBar. I have this process running perfectly.
After you click the CommandButton, the Macro is in perfect
sync with the completion of the ProgressBar reaching 100%,
except that when the Userform that displays the ProgressBar
is instructed to unload, it unloads leaving a white area
where the UserForm was. The white area doesn't completely
disappear until the worksheet updates all of the changes,
about 12 seconds.
How can I make the UserForm remain displayed with the 100%
finished ProgressBar while the worksheet finishes it's 12
seconds of updating?




John Tjia

ProgressBar Out of Sync
 
The white area could be the result of the code

Application.ScreenUpdating=False

somewhere. Try putting in the code Application.ScreenUpdating=TRUE
right before you unload the form.


"RDallas" wrote in message ...
Hope you can help, I have created a UserForm with multiple
CommandButtons, each CommandButton runs a lengthy Macro.
The Code for the Macro is running inside a loop that
updates a ProgressBar. I have this process running perfectly.
After you click the CommandButton, the Macro is in perfect
sync with the completion of the ProgressBar reaching 100%,
except that when the Userform that displays the ProgressBar
is instructed to unload, it unloads leaving a white area
where the UserForm was. The white area doesn't completely
disappear until the worksheet updates all of the changes,
about 12 seconds.
How can I make the UserForm remain displayed with the 100%
finished ProgressBar while the worksheet finishes it's 12
seconds of updating?



All times are GMT +1. The time now is 11:48 PM.

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