End a procedure form a UserForm

S

Sam

I use a MsgBox with vbYesNoCancel to end a procedure if the No button is
clicked. However, the end users don't take the time to read the message and
just click Yes to get past it.

I want to use a LARGE UserForm with Yes & No command buttons to accomplish
the same thing. If the end user clicks Yes, the UserForm will unload and the
procedure will continue. What code can I put into the No command button to
end the procedure that launched the UserForm when the No button is clicked?

Thanks,

Sam
 
J

JLGWhiz

Unload UserForm1 'or whatever number it is.

This takes control back to the macro that showed the UserForm.
 
J

JLGWhiz

This might be more clear.

If you put a command button on the form:

Private Sub CommandButton1_Click()
Unload Me
End Sub

If you put a command button on a sheet:

Private Sub CommandButton1_Click()
Unload UserForm1
End Sub
 

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