Sub Demo1()
Dim L&, Rg(3) As Range, V, F%, D&, R&
With Application
.EnableEvents = False
.ScreenUpdating = False
With [A1].CurrentRegion.Rows
L = .Count
.Sort .Cells(7), 1, Header:=1
Set Rg(1) = .Columns(7).Find(0, , , 1, , 2)
If Rg(1) Is Nothing Then
V = Application.Lookup(0, .Columns(7))
If IsError(V) Then Erase Rg: Exit Sub
Set Rg(1) = .Columns(7).Find(V, , , 1, , 2)
If Rg(1).Row = L Then Erase Rg: Exit Sub
Set Rg(0) = .Range(.Cells(2, 7), Rg(1))
Else
Set Rg(0) = .Columns(7).Find(0, , , 1, , 1)
If Rg(0).Row = 2 Then
With .Range(Rg(0), Rg(1)): .Value2 = Empty: L = L - .Rows.Count: End With
.Sort .Cells(7), Header:=1
ElseIf Rg(1).Row = L Then
L = L - .Range(Rg(0), Rg(1)).Rows.Count
End If
If L < .Count Then .Item(L + 1 & ":" & .Count).Clear: Erase Rg: Exit Sub
With .Range(Rg(0), Rg(1)): .Value2 = Empty: L = L - .Rows.Count: End With
Set Rg(0) = .Range(.Cells(2, 7), Rg(0)(0))
End If
Set Rg(1) = .Range(Rg(1)(2), .Cells(.Count, 7))
F = 1 + (Rg(0).Count > Rg(1).Count)
For Each Rg(2) In Rg(1 - F)
Set Rg(3) = Rg(F).Find(-Rg(2).Value2, , , 1, , 1)
If Not Rg(3) Is Nothing Then
D = Rg(2)(1, -2).Value2
R = Rg(3).Row
Do
If Rg(3)(1, -2).Value2 = D Then L = L - 2: Union(Rg(2), Rg(3)).Value2 = Empty: Exit Do
Set Rg(3) = Rg(F).FindNext(Rg(3))
Loop Until Rg(3).Row = R
End If
Next
If L < .Count Then .Sort .Cells(7), Header:=1: .Item(L + 1 & ":" & .Count).Clear
End With
.DisplayAlerts = True
.ScreenUpdating = True
End With
Erase Rg
End Sub