Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = [TotalVal].Row - 1 Then
Application.EnableEvents = False
[TotalVal].EntireRow.Insert
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = [TotalVal].Row - 1 Then
Application.EnableEvents = False
[TotalVal].EntireRow.Insert
Application.EnableEvents = True
End If
If Target.Row = [TotalVal].Row - 2 Then
Application.EnableEvents = False
[TotalVal].EntireRow.delete
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rCell As Range
If Not Intersect(Target, Range("TotalVal").EntireColumn) Is Nothing Then
Application.EnableEvents = False
For Each rCell In Intersect(Target, Range("TotalVal").EntireColumn).Cells
If rCell.Row = Range("TotalVal").Row - 1 Then
If Len(rCell.Value) > 0 Then
Range("TotalVal").EntireRow.Insert
Else
rCell.EntireRow.Delete
End If
ElseIf Len(rCell.Value) = 0 Then
rCell.EntireRow.Delete
End If
Next rCell
Application.EnableEvents = True
End If
End Sub
ElseIf Len(rCell.Value) = 0 Then
ElseIf Len(rCell.Value) > 0 Then
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rCell As Range
Dim rDelete As Range
If Not Intersect(Target, Range("TotalVal").EntireColumn) Is Nothing Then
Application.EnableEvents = False
For Each rCell In Intersect(Target, Range("TotalVal").EntireColumn).Cells
If rCell.Row = Range("TotalVal").Row - 1 Then
If Len(rCell.Value) > 0 Then
Range("TotalVal").EntireRow.Insert
Else
If rDelete Is Nothing Then
Set rDelete = rCell
Else
Set rDelete = Union(rDelete, rCell)
End If
End If
ElseIf Len(rCell.Value) = 0 Then
If rDelete Is Nothing Then
Set rDelete = rCell
Else
Set rDelete = Union(rDelete, rCell)
End If
End If
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
Application.EnableEvents = True
End If
End Sub
Try this version:
Code:Private Sub Worksheet_Change(ByVal Target As Range) If Target.Row = [TotalVal].Row - 1 Then Application.EnableEvents = False [TotalVal].EntireRow.Insert Application.EnableEvents = True End If End Sub