Msg box w/ cancel option

boxsterman

Active Member
Joined
Apr 16, 2002
Messages
285
Hi all,

I have the standard message box in my code

msgbox ("Continue?")

How do I include with with a cancel option - I want to give the user the option to abort the VBA script if they haven't completed a task.

Thanks,

J
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Check out the second argument of MsgBox in VBA help, it gives you a list of options to choose, i.e.

MsgBox "Continue", vbOKCancel
will display both "OK" and "Cancel"
 
Upvote 0
Hi - thanks for the tip,

However when I press cancel, it still continues with the VBA script - I need it to cance when cancel is selected.

J.
 
Upvote 0
Here is a little script that displays how you can handle the reply:
Code:
    Dim myReply
    myReply = MsgBox("Continue", vbOKCancel)
    If myReply = vbOK Then
        MsgBox "Continuing on..."
    Else
        MsgBox "Process cancelled"
    End If
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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