如果另外满足另外三列 E、G、H、M、N 的条件,我将尝试删除从 K 列中相互偏移的项目的行。
!(因此,如果 E、G、H、M、N 列中的条件相同,并且 K 列中我们有抵消金额,则应删除该行。 有人可以帮我吗?)
这个宏可以帮助你:
Sub DeleteRows()
Dim i As Long, j As Long, lr As Long, a() As Boolean
lr = [E2].End(xlDown).Row
ReDim a(2 To lr) As Boolean
For i = 2 To lr - 1
If Not a(i) Then
For j = i + 1 To lr
If Not a(j) And Cells(j, "E") = Cells(i, "E") _
And Cells(j, "G") = Cells(i, "G") _
And Cells(j, "H") = Cells(i, "H") _
And Cells(j, "M") = Cells(i, "M") _
And Cells(j, "N") = Cells(i, "N") _
And Cells(j, "K") = -Cells(i, "K") _
Then
a(i) = True: a(j) = True
Exit For
End If
Next
End If
Next
For i = lr To 2 Step -1
If a(i) Then Rows(i).Delete
Next
End Sub