mmkoll
06-25-2014, 08:57 AM
hey there this is my first post so :hi:
My code is working but it got a problem and i dont know how to fix it.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Application.EnableEvents = False
If Not Application.Intersect(Target, Me.Range("D8:K29")) Is Nothing Then
r = Target.Row
c = Target.Column
While Not IsEmpty(Cells(r, c).Value)
Cells(r, c).Value = Cells(6, c).Value - Cells(r, c).Value
c = c + 1
Wend
Application.EnableEvents = True
End If
End Sub
what the code thoes it subtract a valor that you tipe from other that is in the table.
A
b
c
d
e
f
1
14
15
12
12
2
=sum(b2:e2)
3
4
5
ok this is example of my table.
every time you insert a number in the range(b2:e5) it subtract that number from the respective range(a1:e1)
ex: if you insert a valor in b2 valor "3" the valor of b2 will be "11"
all good till there, the problem is the last column range(e2:e5) wend i insert a valor, dosent show the right result and it erases the formula in f2.
I attach my real table in the post that reflects my code.
can anywone help?
Tanks in advance
My code is working but it got a problem and i dont know how to fix it.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Application.EnableEvents = False
If Not Application.Intersect(Target, Me.Range("D8:K29")) Is Nothing Then
r = Target.Row
c = Target.Column
While Not IsEmpty(Cells(r, c).Value)
Cells(r, c).Value = Cells(6, c).Value - Cells(r, c).Value
c = c + 1
Wend
Application.EnableEvents = True
End If
End Sub
what the code thoes it subtract a valor that you tipe from other that is in the table.
A
b
c
d
e
f
1
14
15
12
12
2
=sum(b2:e2)
3
4
5
ok this is example of my table.
every time you insert a number in the range(b2:e5) it subtract that number from the respective range(a1:e1)
ex: if you insert a valor in b2 valor "3" the valor of b2 will be "11"
all good till there, the problem is the last column range(e2:e5) wend i insert a valor, dosent show the right result and it erases the formula in f2.
I attach my real table in the post that reflects my code.
can anywone help?
Tanks in advance