title: VBA code to check if the result of formula is negative and if negative pop up a msgbox stating the error
body: <p>I have following code, however this code is work in progress:</p>
  <p><img src="https://i.stack.imgur.com/dHJ9X.png" alt="enter image description here" /></p>
  <p>My intentions are to use table name instead of cell name (f7 and h7). Formula used in the sheet is</p>
  <pre><code>Pending Quantity (column f) = Total quantity(Column Issue till date (column e) -((issue from FSD Harduaganj (column g)) + (issue from SWC Aligarh (column H))) 
  </code></pre>
  <p>and VBA code is to check if the entered quantity in column g or h makes the pending quantity negative, then clear that entered quantity.</p>
  <p>Here is the current code, the code is referring to f7 and h7 however I intend to use it on whole column like... if I enter data in next row it should check if the pending quantity is negative if negative it should remove/clear the last entry from column g or h of that row.</p>
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
      Dim entrycell As Range
      Set Target = Me.Range(&quot;f7&quot;)
      Set entrycell = Me.Range(&quot;H7&quot;)
  
      If Target.Value &lt; 0 Then
          MsgBox (&quot;This Value must be a number of zero or greater.&quot;), , &quot;Invalid Entry&quot;:entrycell.ClearContents
      End If
  End Sub
  </code></pre>