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
 
Top