ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to cancel a macro once started? (https://www.excelbanter.com/excel-programming/419223-how-cancel-macro-once-started.html)

John[_22_]

How to cancel a macro once started?
 
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


Daniel.C[_2_]

How to cancel a macro once started?
 
Try :
answ = MsgBox("Are you really sure ?", vbYesNo)
If answ = vbNo Then Exit Sub
' delete
Regards.
Daniel

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




John[_22_]

How to cancel a macro once started?
 
Thank you Daniel
It works great
Have a nice day
John
"Daniel.C" wrote in message
...
Try :
answ = MsgBox("Are you really sure ?", vbYesNo)
If answ = vbNo Then Exit Sub
' delete
Regards.
Daniel

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





Charlotte E.[_2_]

How to cancel a macro once started?
 
A one liner:

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


CE



John wrote:
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




John[_22_]

How to cancel a macro once started?
 
Thanks Charlotte
Works great
Regards
John
"Charlotte E." <@ wrote in message
...
A one liner:

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


CE



John wrote:
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





maperalia

How to cancel a macro once started?
 
Daniel;
Thanks very much for the code. It is working wonderfully!!!!!!

Kind regards.
Maperalia

"Daniel.C" wrote:

Try :
answ = MsgBox("Are you really sure ?", vbYesNo)
If answ = vbNo Then Exit Sub
' delete
Regards.
Daniel

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






All times are GMT +1. The time now is 04:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com