How to cancel a macro once started?

  • Thread starter Thread starter John
  • Start date Start date
J

John

I know nothing about VBA except the recorder and able to modify a bit.
I have a macro to erase a form that is activated with a button. I would like
to be able to
have a message to confirm the deletion (Msgbox ) but have the choice to say
no and stop the macro from erasing.
I would appreciate any help please
Thanking you in advance
John
 
Try :
answ = MsgBox("Are you really sure ?", vbYesNo)
If answ = vbNo Then Exit Sub
' delete
Regards.
Daniel
 
Thanks Charlotte
Works great
Regards
John
Charlotte E. said:
A one liner:

If MsgBox("Do you want to delete?", vbYesNo + vbQuestion, "Confirm
Delete") = vbNo Then Exit Sub


CE
 
Daniel;
Thanks very much for the code. It is working wonderfully!!!!!!

Kind regards.
Maperalia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top