Warning Message Needed for User Who "X" Out of Certain Form


Board Regular
Oct 5, 2009
I am attempting to have a pop message display when users of a certain form "X" out of the form. Below is what I came up with but it does not seem to be working:

Private Sub IntroUpdate_BeforeClose(Cancel As Boolean)
Call MsgBox("User closed the program before any formulas were updated.", vbExclamation, ".: ALERT: FM Program Tabs :.")
End Sub
Currently the above is in the code section of the form (titled: IntroUpdate).

Also if the form unloads I do not want the message displayed - only in the event that a user "X" out of the specific form titled: IntroUpdate).

Thanks as always for your help


MrExcel MVP
Sep 2, 2009
Try this...

[color=darkblue]Private[/color] [color=darkblue]Sub[/color] UserForm_QueryClose(Cancel [color=darkblue]As[/color] [color=darkblue]Integer[/color], CloseMode [color=darkblue]As[/color] [color=darkblue]Integer[/color])
    [color=darkblue]If[/color] CloseMode = 0 [color=darkblue]Then[/color]
        MsgBox "User closed the program before any formulas were updated.", _
               vbExclamation, ".: ALERT: FM Program Tabs :."
    [color=darkblue]End[/color] [color=darkblue]If[/color]
End [color=darkblue]Sub[/color]
Don't change the name of the procedure. It's required to be called UserForm_QueryClose
Last edited:

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...