I am new to VBA. I am having an issue with a MsgBox and I can't seem to find the answer. So heres the explanation. If the value of a certain cell is <0 then the user is trying to issue payments over a maximum amount allowable (which on a very rare occasion has to happen). I have created a pop up to ask Yes/No to continue with the payment. If they press NO then it undoes the last entry and they can reenter the payment.
But if they click YES the pop-up goes away which is what I want, but it keeps popping up anytime you try and do anything else on the spreadsheet because the value continues to be <0. How do I make the msgbox stop completely when they press yes?
This is my code so far:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("C39") < 0 Then
If MsgBox("Total cash flow/payout cannot exceed maximum contract amount" & vbCrLf & "Do you want to continue?", vbYesNo + vbCritical, "WARNING") = vbNo Then
Application.Undo
End If
End Sub