VBA code to make a progress tool bar work

J

Jeff Marshall

Hi,
Does anyone have some code that would make a progress tool bar work in a
UserForm1.
I would like to use it in a For loop where it shows the status of the
variable C.

For example;

For C = 1 to 25000
'Code goes here

UserForm1 goes here with progess bar in it showing the % complete as C goes
from 1 to 25000.

Next C

Thanks
Jeff
 
T

Tom Ogilvy

Userform1.show vbModeless
Userform1.ProgressBar1.Value = 0
For C = 1 to 25000
'Code goes here

With Userform1.ProgressBar1
.value = c/25000 * (.max - .min)
Doevents
End With

Next C

Unload Userform1
 
B

Bob Phillips

Jeff,

John Walkenbach has a nice example on his site at
http://j-walk.com/ss/excel/tips/tip34.htm.

The thing to note is that you have to control it. You have to know how to
determine progress so that you can call the progressbar routine. Taking a
simplistic example, if you have a loop that executes 250 times, every 25
cycles you call the progressbar incrementing by 10%.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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