ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   must I travel through UserForm_activate event? (https://www.excelbanter.com/excel-programming/348586-must-i-travel-through-userform_activate-event.html)

Dave B[_9_]

must I travel through UserForm_activate event?
 
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.)


Dick Kusleika[_4_]

must I travel through UserForm_activate event?
 
Dave B wrote:
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.

--
Dick Kusleika
MVP-Excel
www.dailydoseofexcel.com




All times are GMT +1. The time now is 05:34 PM.

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