Can you trap the Close button (red X) on a Userform?

R

rick

Is it possible to get an error code or an event when the user clicks on the
form close button?

Thanks.

... rick
 
D

Dave Peterson

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
msgbox "You clicked the X"
End If
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