Stop UserForm From Closing via X

< Back to Search results

 Category: [Excel]  Demo Available 

Stop UserForm From Closing via X


Prevent Closing of UserForm via Top Right X

Got any Excel/VBA Questions? Excel Help


Stop Top Right X Click

The code below can be placed in the Private Module of any UserForm Object to prevent any users closing the Excel UserForm via the top right X. It makes use of UserForm_QueryClose Event to capture the click on the top right X. The Cancel being set to True prevents the UserForm from closing when the top right X is clicked.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

        If CloseMode = 0 Then Cancel = True

End Sub


See also:

Index to Excel VBA Code
Transpose Rows Into Columns
Excel Lookup nth Occurrence/Instance
Add Excel UDF/Custom Function to a Category & Add a Description
The Ultimate Excel Lookup Function
Update Links in Excel


See also Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions.


Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


stars (0 Reviews)