I'm not sure this is what you want, but try it anyway.
Sub Test()
Dim foundCell As Range
Dim firstCell As Range
Dim value1, value2
value1 = 1
value2 = -1
With Range("A:A")
Set foundCell = .Find(What:=value1, LookAt:=xlWhole)
If Not foundCell Is Nothing Then
foundCell.EntireRow.Insert Shift:=xlDown
Set firstCell = foundCell
Do
Set foundCell = .FindNext(foundCell)
If foundCell.Address = firstCell.Address Then
Exit Do
Else
foundCell.EntireRow.Insert Shift:=xlDown
End If
Loop
End If
Set foundCell = .Find(What:=value2, LookAt:=xlWhole)
If Not foundCell Is Nothing Then
If WorksheetFunction.CountA(foundCell.Offset(-1).EntireRow) > 0 Then
MsgBox "Can't delete row, row contains value"
Else
foundCell.Offset(-1).EntireRow.Delete
End If
Set firstCell = foundCell
Do
Set foundCell = .FindNext(foundCell)
If foundCell.Address = firstCell.Address Then
Exit Do
Else
If WorksheetFunction.CountA(foundCell.Offset(-1).EntireRow) > 0 Then
MsgBox "Can't delete row, row contains value"
Else
foundCell.Offset(-1).EntireRow.Delete
End If
End If
Loop
End If
End With
End Sub
Bookmarks