MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Closing Other Subs Within A Userform

Posted by Sam on August 07, 2001 2:25 PM

I am running a userform that runs a sub within a module. I was wondering if anyone knows how to have a message come up when the user clicks the 'X' button on the userform that asks if they really want to exit. If the user say yes, it unloads the userform and the sub.

Thanks in advanced,

Posted by Cory on August 07, 2001 2:41 PM

check out this post:


it shows how to asign code to the 'X' button on the userform...


Posted by Sam on August 07, 2001 3:02 PM

I already have the code set up I was just wondering if there was a way to exit another sub from this one.


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 Exit From sub AngCalc1 but not sure how ******

Exit Sub
End If
End If
End Sub