You are close, try this belowPrivate Sub UserForm_QueryClose(Cancel As Integer, CloseMode AsInteger)If CloseMode = VbQueryClose.vbFormControlMenu ThenCancel = TrueEnd IfEnd Sub