MsgBox modification to include clicking the "X"

zombiemaster

Board Regular
Joined
Oct 27, 2009
Messages
245
I have a simple Yes/No message box that will exit the sub if the user clicks "no". I saw on another forum where someone mentioned that we can "add another condition to test the user's response for something else in addition to vbYes (perhaps to test for no response by clicking the X to close the form)", but they didn't actually provide the code...

I haven't been able to find that code that will also exit the sub if the user clicks the ":crash:" to exit the message box instead of clicking one of the buttons. I figured if I'd find someone who knew the answer, it would be here... :)

Here is my existing message box VBA:

Code:
    Dim varResponse As Variant
    
    varResponse = MsgBox("                      --==BEFORE RUNNING THIS REPORT==--" 
& vbCrLf & vbCrLf & "--==DOWNLOAD TODAY'S REPORT FROM DOC DIRECT==--" 
& vbCrLf & vbCrLf & "               Have you downloaded the report from Doc Direct?", 
vbYesNo, "Selection")
    If varResponse <> vbYes Then Exit Sub

Thanks for your help as always!
~ZM~
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
No need to test for clicking the "X" with that code, as you can't, it's disabled.
 
Upvote 0
:eeek: WOW :eeek:

Is today Monday? Because this just made me FEEL like it's a Monday...

Thanks for the quick help, Fluff!!

:cool:
~ZM~
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top