Excel 怎样用VBA代码实现自动查找重复行并删除

如题所述

选定要查找的列,点数据,删除重复项

温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-11-04
以A列出现重复删除为例:

Sub 删除重复行()
Application.ScreenUpdating = False

Dim i, j

For i = [A65536].End(3).Row To 1 Step -1
For j = i - 1 To 1 Step -1
If Cells(i, 1) = Cells(j, 1) Then
Rows(i).Delete
End If
Next
Next

Application.ScreenUpdating = True

End Sub本回答被网友采纳
第2个回答  推荐于2018-05-12
字典 CreateObject("scripting.dictionary")
我的一段代码,供参考。
Set d = CreateObject("scripting.dictionary")
For Each Rng In Worksheets("原始表").Range("c1:c" & Rcount)
If Not d.exists(Rng.Value) And Worksheets("原始表").Cells(Rng.Row, 1) = 2 Then d.Add Rng.Value, ""
Next
Worksheets("支路模块矩阵").Range("b1").Resize(1, d.Count) = d.keys
Set d = Nothing本回答被网友采纳
第3个回答  2018-05-12
Sub www()
    Dim x%, y%
    x = 1
    Do While Cells(x, 1) <> ""
        y = x + 1
        Do While Cells(y, 1) <> ""
            If Cells(x, 1) = Cells(y, 1) Then Rows(y & ":" & y).Delete
            y = y + 1
        Loop
        x = x + 1
    Loop
End Sub

相似回答