Hello,
I would like to create a pop-up message box when you try to close an excel file.
The idea is that the message is asking a question with a YES/NO answer. If you push YES, the file stays open and if you push NO then there will be a second message box and there if you push OK then the file will be closed.
I have found the following code on the internet, but it doesn´t seem to do what is needed.
I´m a total newbie when it comes to VBA.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim answer As String
Dim question As String
question = "ATTENTION! Your offer is not acceptable! You should lower the price!"
answer = MsgBox(question, vbYesNo)
If answer = vbNo Then
MsgBox "You should be more Customer focused! Go back?"
Cancel = True
Exit Sub
Else
ThisWorkbook.Save
End If
End Sub
Appreciate any support!
Thank you!
I would like to create a pop-up message box when you try to close an excel file.
The idea is that the message is asking a question with a YES/NO answer. If you push YES, the file stays open and if you push NO then there will be a second message box and there if you push OK then the file will be closed.
I have found the following code on the internet, but it doesn´t seem to do what is needed.
I´m a total newbie when it comes to VBA.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim answer As String
Dim question As String
question = "ATTENTION! Your offer is not acceptable! You should lower the price!"
answer = MsgBox(question, vbYesNo)
If answer = vbNo Then
MsgBox "You should be more Customer focused! Go back?"
Cancel = True
Exit Sub
Else
ThisWorkbook.Save
End If
End Sub
Appreciate any support!
Thank you!