Msgbox not working properly

wwbwb

Well-known Member
Joined
Oct 20, 2003
Messages
513
Why won't this work??? If I hit cancel it works fine, but if I hit OK, it still exits the sub and does NOT call the other macro... :oops:
Code:
Private Sub CommandButton1_Click()
MsgBox "Once you do this, the only way to get the information back is to close the workbook, DO NOT save, and reopen it!", _
 vbExclamation + vbOKCancel, "WARNING!"
If vbCancel Then Exit Sub
If vbOK Then Call Budgetdelete
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
This should work for you:

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> CommandButton1_Click()

    x = MsgBox("Once you do this, the only way to get the information back is to close the workbook, DO NOT save, and reopen it!", vbExclamation + vbOKCancel, "WARNING!")

    <SPAN style="color:#00007F">If</SPAN> x = vbCancel <SPAN style="color:#00007F">Then</SPAN> MsgBox "Cancel"
    <SPAN style="color:#00007F">If</SPAN> x = vbOK <SPAN style="color:#00007F">Then</SPAN> MsgBox "Ok"

<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,834
Members
449,051
Latest member
excelquestion515

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