Forum Discussion

hopr37 hotmail's avatar
hopr37 hotmail
Brass Contributor
Mar 27, 2018
Solved

Keep number from changing after setting cell back to zero

3 colums 1st column is the starting total 2nd column is the amount subtracted from the 1st column 3rd column is the new total by subtracting the 1st and 2nd columns Question: After subtracti...
  • Jamil's avatar
    Mar 28, 2018

    hopr37

     

    This can be done with few lines of VBA code which i wrote below. please see the attached workbook.

     

     

     

     

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B2", Range("B" & Rows.Count).End(xlUp))) Is Nothing Then
    Application.EnableEvents = False
    If Target > 0 Then
    Target.Offset(, 1).Value2 = Target.Offset(, -1).Value2 - Target.Value2
    End If
    End If
    Application.EnableEvents = True
    End Sub
    

     

Resources