End routine by clicking 'X' on Userform

A

Arnie

Hello,

I have a routine which calls a Userform. On the userform someone can make a
choice. After that the routine continues.
But I want to stop the complete routine if someone clicks on the 'X' at the
right corner. How to?

Exit sub won't work this only stops the userform and the main routine still
continues.

Arnie
 
M

Michael

Click on the userform and select view code; from the dropdow box on the code
section select Userform, then from the events dropdow select Terminate
You will get the following:
Private Sub UserForm_Terminate()

End Sub

Type End in between the Sub and end Sub instructions

If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.
 
A

Arnie

Thanx!
Michael said:
Click on the userform and select view code; from the dropdow box on the
code
section select Userform, then from the events dropdow select Terminate
You will get the following:
Private Sub UserForm_Terminate()

End Sub

Type End in between the Sub and end Sub instructions

If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.
 
P

Peter T

Never use the 'End' statement.

Look at the QueryClose Event in the Userform and help.

If still not sure how to terminate your app cleanly describe what is
running, eg code returns to the routine that show'd a Modal Userform, other
forms still running, etc.

Regards,
Peter T
 

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