using of progress bar

R

Rob van Gelder

Of all the progressbars I've seen, your main code needs to advance the
progress bar itself.
I've not seen any asynchronous examples - not even marquee progress bars in
Excel.

example Pseudocode of main code:

Initialise progress bar
for 1 to 100
do something
advance progress bar by 1
next
exit progress bar


I have some progress bars on my website.
 
G

Guest

Hello Robin,

thank you for your reply.
I try and explain it once again.

My macro has following structure:

Sub Main()
Sub 1()
Sub 2()
Sub 3()
...
...
...
Sub n()
End Sub

Macro usually takes from 20s up to 1min, depends on data volume
I would like to know where to place the subroutine "ProgBarDemo" in my code,
eventually how to adjust progressbar code (counter etc...) in order to the
progressbar displays duration of whole macro.

Maybe the solution is simple but I am a beginner in WBA programming :)

thanks

Jan
 
R

Robin Hammond

Jan,

It would look something like this

Sub Main
Dim PB as clsProgBar
Set PB = new clsProgBar

'if your subs are being called from a userform, hide the form first using
Me.Hide
With PB

.title = "some title"
.caption1 = "Executing, this may take a while"
.caption2 = "Doing task 1"
.show
doevents

end with

Sub1 x,y,z
pb.progress = 10
pb.caption2 = "doing task 2"

Sub2 a,b,c,d
PB.progress = 20
pb.caption2 = "doing task 3"

'etc,
'and at the end

Sub10
PB.finish

'if called from a userform, show the form again, using me.show
End Sub
 
G

Guest

thanks Robin

that works perfectly

Jan


Robin Hammond said:
Jan,

It would look something like this

Sub Main
Dim PB as clsProgBar
Set PB = new clsProgBar

'if your subs are being called from a userform, hide the form first using
Me.Hide
With PB

.title = "some title"
.caption1 = "Executing, this may take a while"
.caption2 = "Doing task 1"
.show
doevents

end with

Sub1 x,y,z
pb.progress = 10
pb.caption2 = "doing task 2"

Sub2 a,b,c,d
PB.progress = 20
pb.caption2 = "doing task 3"

'etc,
'and at the end

Sub10
PB.finish

'if called from a userform, show the form again, using me.show
End Sub
 
G

Guest

the previous posts have been helpful, but when I hit cancel on the progress
bar... the rest of my code continues running. How do I end my code if I
press cancel on the progress bar?

Thanks!
 

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