I need a code to stop the other codes from running if the sum of cells O16:O26 do not equal cell O10. Also need the msgbox warning. This is what I've found so far. It's not working for me. Can anyone help?
I currently have a command button set to run 2 other codes. Should this stop code be written onto Sheet1 in VBA? Or can it be a separate module and added to the top of the button click list?
Thanks for all the help today!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Application.WorksheetFunction.Sum(Range("O16:O26")) <> (Range("O10")) Then
MsgBox "Distribution amt does not match total amount"
End If
End Sub
I currently have a command button set to run 2 other codes. Should this stop code be written onto Sheet1 in VBA? Or can it be a separate module and added to the top of the button click list?
Thanks for all the help today!