EXCEL MsgBox Confirmation of Macro Execution
Solved
laptitepero
Posted messages
19
Status
Member
-
loloonthewave -
loloonthewave -
Hello!
Here's my question:
I have a macro that deletes rows, and I have put an execution button on my sheet.
(So far, so good.)
Now I would like to create a confirmation message to confirm executing the macro if someone clicks on this button.
While searching a bit, I found this macro:
Sub MyFunction()
If MsgBox("Irreversible operation. Do you wish to continue?", vbQuestion + vbYesNo, "QUESTION ...") = vbYes Then
...
...
...
Else
...
End If
...
End Sub
But I can't apply it to mine (the ..... don't help me).
Thank you for your help.
Laptitepero
Here's my question:
I have a macro that deletes rows, and I have put an execution button on my sheet.
(So far, so good.)
Now I would like to create a confirmation message to confirm executing the macro if someone clicks on this button.
While searching a bit, I found this macro:
Sub MyFunction()
If MsgBox("Irreversible operation. Do you wish to continue?", vbQuestion + vbYesNo, "QUESTION ...") = vbYes Then
...
...
...
Else
...
End If
...
End Sub
But I can't apply it to mine (the ..... don't help me).
Thank you for your help.
Laptitepero
5 answers
-
Hello,
The error is here:
If vbCancel Then Exit Sub Else End If
It should be:If yourmsgbox = vbCancel Then Exit Sub End If
;o)
“What one conceives well is clearly expressed, and the words to say it come easily.”
Nicolas Boileau -
Hello everyone,
I have exactly the same problem as lapetitepero, but your information is not helping me.
My syntax is as follows:yourmsgbox = MsgBox("Are you sure you validate?", vbOKCancel, "confirmation") If vbCancel Then Exit Sub Else End If
Then my code to execute if you click on Ok is located here.
In this case, whether I click on Ok or Cancel, it's the cancel case that executes. But where is the error? -
Hello,
The "little dots" are the code that must be executed, that is to say your code.
Sub MyFunction() If MsgBox("Irreversible operation. Do you want to continue?", vbQuestion + vbYesNo, "QUESTION ...") = vbYes Then ' YOUR CODE IF THE ANSWER IS "YES" Else ' YOUR CODE IF THE ANSWER IS "NO" End If End Sub
;o)
--
“What is well conceived is clearly said, And the words to say it come easily.”
Nicolas Boileau -
If it can help you,
here is my basic macro:
Sub SuppLigne() Dim Lig As Long Sheets("Modèle").Select Lig = ActiveCell.Row Rows(Lig).Delete Sheets("Résultat").Rows(Lig).Delete Sheets("Constantes").Rows(Lig).Delete End Sub -
Yahoo, everything is working great!
Thank you very much!