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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
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,827
Messages
6,121,816
Members
449,049
Latest member
cybersurfer5000

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