MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Closing other subs within a userform

Posted by Sam on August 08, 2001 9:13 AM

I am using a userform that calls a sub within a module. I was wondering if anyone knows how to exit the other sub after the userform is closed.

'(sub angcalc1 is already running under this userform)

Private Sub UserForm_QueryClose _
(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
iYesNo = MsgBox("Are Yo Sure You Want To Close The Angle Calculator?", vbYesNo)
If iYesNo = vbNo Then
Cancel = True
ElseIf iYesNo = vbYes Then
Unload AngCalcForm
MsgBox ("To Exit The Angle Calculator Press Esc")

**** Need To close sub AngCalc1 here but not sure how ******

Exit Sub
End If
End If
End Sub



Posted by Cory on August 08, 2001 9:54 AM

What I don't understand is if you "unload userform", the form is removed from memory thus ending all subs. Is the userform you unloaded on top of another (one which you want closed?). If not, them what exactly is the AngCalc1 sub and how does it play into the rest of your code?

With that I think I can answer your question. I've been trying to figure out your earlier post where we were discussing this, but couldn't get past these questions...


Posted by Sam on August 08, 2001 10:33 AM

I'm sorry about the confusion. I'm probably not making the problem clear.

The user form that I am using is a progression bar indicator. It monitors the progress of another sub "AngCalc1" which is not located within that userform. It is in a seperate module. When I close the userform, it exits the progression indicator but not "AngCalc1", this is still running. I would like for it to close both the user form and exit "AngCalc1" when the X box is clicked. Hope this helps. I could give the codes too if that would help to clarify more.


Posted by Cory on August 08, 2001 12:42 PM

I understand now. Unfortunatly that's beyond the scope of my knowlegde. Sorry...