我需要删除列“E”中所有单元格中唯一的行,因此我的列中只有“非唯一”单元格,即“E”列只有重复。
我一直在寻找代码来做到这一点,但发现很少。
对不起,我甚至无法发布一个剪辑来开始。
由于
答案 0 :(得分:0)
尝试一下:
Sub RemoveUniques()
Dim E As Range, rDel As Range, r As Range, N As Long
N = Cells(Rows.Count, "E").End(xlUp).Row
Set E = Range("E1:E" & N)
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
Set rDel = Nothing
For Each r In E
v = r.Value
If wf.CountIf(E, v) = 1 Then
If rDel Is Nothing Then
Set rDel = r
Else
Set rDel = Union(rDel, r)
End If
End If
Next r
If Not rDel Is Nothing Then
rDel.EntireRow.Delete
End If
End Sub