I am trying to make a msgbox that will come up under a before close event if a condition is met. If they answer yes then I want another message box to pop up and then they can close the application. This part seems to be working fine. The problem I have is if they answer no then I want excel to not close and I can't seem to get this to work.
This is what I have so far:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Range("M10") < Range("R10") Then MsgBox "You are about to exit the worksheet and your final average is negative this means that the entire shift average has failed and all product must be held, Are you sure you would like to exit?", vbYesNo
If vbYes Then MsgBox ("All product for this SKU must be held for the entire shift")
Exit Sub
If vbNo Then xlApp.Close = False
Exit Sub
End Sub
Any ideas?