yes you're right because the last row is just B as in the code
in reality I try doing without loop but I think showing error start from row8 . you can test it for two choices.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Or Target.Row < 1 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 2 And Target.Row > 1 Or Target.Column = 5 And Target.Row > 1 Then
lr = Range("B" & Rows.Count).End(xlUp).Row
lr1 = Range("E" & Rows.Count).End(xlUp).Row
Range("G9:G" & lr & ":G9:G" & lr1).FormulaR1C1 = "=RC[-5]+R[-1]C-RC[-2]"
End If
Application.EnableEvents = True
End Sub
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Or Target.Row < 1 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 2 And Target.Row > 1 Or Target.Column = 5 And Target.Row > 1 Then
lr = Range("E" & Rows.Count).End(xlUp).Row
Range("G9:G" & lr ).FormulaR1C1 = "=RC[-5]+R[-1]C-RC[-2]"
End If
Application.EnableEvents = True
End Sub
I no know if there is idea to fix that by Alex or others members.
in this work , but with loop . you can also test it
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Or Target.Row < 1 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 2 And Target.Row > 1 Or Target.Column = 5 And Target.Row > 1 Then
lr = Range("E" & Rows.Count).End(xlUp).Row
For i = 9 To lr
Range("G9:G" & lr).FormulaR1C1 = "=RC[-5]+R[-1]C-RC[-2]"
Next i
'Range("G9:G" & lr).Value=Range("G9:G" & lr).Value
End If
Application.EnableEvents = True
End Sub