PDA

View Full Version : Solved: Progress bar till the macro is done



white_flag
02-24-2012, 02:54 AM
http://www.mrexcel.com/forum/showthread.php?p=3054951#post3054951

Hello
I like to add an progress bar when macro from excel is running and I putted like this:

A button in worksheet that will fire up UserForm1

in module:


Sub ShowMe1()
UserForm1.Show
End Sub

in userform I have a progressBar1
then, inside of the UserForm1


Sub UserForm_Initialize()
macro1
End Sub

Sub macro1()
'some code

UserForm1.ProgressBar1.Value = 10

'some code

UserForm1.ProgressBar1.Value = 20

'some code

UserForm1.ProgressBar1.Value = 30

' etc

UserForm1.ProgressBar1.Value = 100

Unload UserForm1

End Sub

This approach is correct? if is correct Why I have the following error.
UserForm1.show it is not showing

UserForm1.Show

Bob Phillips
02-24-2012, 03:12 AM
A) I am not understanding what you are saying fully.

B) I make it a personal policy not to help people who cross-post, even when they mark it so as I or others are just wasting our time. Our time is valuable just as much as yours.

Aussiebear
02-24-2012, 03:47 PM
Have a look at Jake's KB entry and go from there

http://www.vbaexpress.com/kb/getarticle.php?kb_id=87

white_flag
02-26-2012, 01:33 PM
Hi xld and Aussiebear

I putted like this:
create an UserForm7 with an progressBar1. hide cancel bottom.
on macro I call userform then I add the values for progressBar1
when the code is going


Sub macro()

Application.EnableCancelKey = xlDisabled

UserForm7.Show
UserForm7.ProgressBar1.Value = 10
UserForm7.Repaint

'some code
UserForm7.ProgressBar1.Value = 20
'some code
UserForm7.ProgressBar1.Value = 30
'some code
UserForm7.ProgressBar1.Value = 40

etc
UserForm7.ProgressBar1.Value = 100

Unload UserForm7

End Sub


I think, it is a bit primitive but It is doing what I need. the missing line was
UserForm7.Repaint

have a nice evening :)

white_flag
02-27-2012, 12:00 AM
I forget:

UserForm need to have Show Modale set as False