must I travel through UserForm_activate event?

D

Dave B

I've made a progress bar using John Walkenbach's template. I don't
show the progress bar right away, so my code looks like this:

Sub MySub()
'some code
frmProgressBar.Show
'more code
End Sub

When I show the userform, it gets stuck in the UserForm_activate event.

My question is, can I return to the "more code" section above, or do I
have to break my code up like this:

Sub MySub1()
'some code
frmProgressBar.Show
End Sub

Sub UserForm_activate() '(in code module for UserForm)
Call MySub2
End Sub

Sub MySub2()
'more code
End Sub

Do I have to break up my main procedure like this? Seems pretty
tedious, and I'm not a fan of breaking my main code into two sub
procedures, but I'll do it if I have to.

Thanks in advance for your help.

As a follow-up, under this structure when I "Unload frmProgressBar"
from within MySub2, will the code progress back through the "End Sub"
of MySub1 as it ends? (Just curious.)
 
D

Dick Kusleika

Dave said:
I've made a progress bar using John Walkenbach's template. I don't
show the progress bar right away, so my code looks like this:

Sub MySub()
'some code
frmProgressBar.Show
'more code
End Sub

When I show the userform, it gets stuck in the UserForm_activate
event.

My question is, can I return to the "more code" section above, or do I
have to break my code up like this:

Sub MySub1()
'some code
frmProgressBar.Show
End Sub

Sub UserForm_activate() '(in code module for UserForm)
Call MySub2
End Sub

Sub MySub2()
'more code
End Sub

Do I have to break up my main procedure like this? Seems pretty
tedious, and I'm not a fan of breaking my main code into two sub
procedures, but I'll do it if I have to.

Thanks in advance for your help.

As a follow-up, under this structure when I "Unload frmProgressBar"
from within MySub2, will the code progress back through the "End Sub"
of MySub1 as it ends? (Just curious.)

Dave:

If you make your userform modeless, it should continue running the sub in
your first example. Change the ShowModal property to False.
 

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