siddheshmumbaikar
New Member
- Joined
- Jan 5, 2021
- Messages
- 4
- Office Version
- 2016
- Platform
- Windows
VBA code would be appreciated.
for eg. D1 has value of 100. if i insert 10 in F1 it should get subtracted from D1 leaving F1 empty for later subractions. and if i insert say 20 in cell G1 it should get added in D1 leaving cell G1 empty for later additions.. actually i got the code for subtraction but i am not able to find code for addition. below is the code for subtraction.
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F7:F200")) Is Nothing Then Exit Sub
Application.EnableEvents = False
With Target
.Offset(, -2).Value = .Offset(, -2).Value - .Value
.ClearContents
End With
Application.EnableEvents = True
End Sub
for eg. D1 has value of 100. if i insert 10 in F1 it should get subtracted from D1 leaving F1 empty for later subractions. and if i insert say 20 in cell G1 it should get added in D1 leaving cell G1 empty for later additions.. actually i got the code for subtraction but i am not able to find code for addition. below is the code for subtraction.
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F7:F200")) Is Nothing Then Exit Sub
Application.EnableEvents = False
With Target
.Offset(, -2).Value = .Offset(, -2).Value - .Value
.ClearContents
End With
Application.EnableEvents = True
End Sub