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
 

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

DRJ

MrExcel MVP
Joined
Feb 17, 2002
Messages
3,853
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>
 

Watch MrExcel Video

Forum statistics

Threads
1,122,482
Messages
5,596,402
Members
414,063
Latest member
N_Bates

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
Top