Add "Are you sure?" to my excel button, how can I? Add "Are you sure?" to my excel button, how can I? vba vba

Add "Are you sure?" to my excel button, how can I?


On your existing button code, simply insert this line before the procedure:

If MsgBox("This will erase everything! Are you sure?", vbYesNo) = vbNo Then Exit Sub

This will force it to quit if the user presses no.


Create a new sub with the following code and assign it to your button. Change the "DeleteProcess" to the name of your code to do the deletion. This will pop up a box with OK or Cancel and will call your delete sub if you hit ok and not if you hit cancel.

Sub AreYouSure()Dim Sure As IntegerSure = MsgBox("Are you sure?", vbOKCancel)If Sure = 1 Then Call DeleteProcessEnd Sub

Jesse


Just make a custom userform that is shown when the "delete" button is pressed, then link the continue button to the actual code that does the deleting. Make the cancel button hide the userform.