Intercept the Close button (X) in the title bar of a user form

Article contributed by Bill Coan

Place the following code into the user form's QueryClose event.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = vbFormControlMenu Then Cancel = True
End Sub

To see how to disable the Close Button entirely, see here:
Disabling the Close Button