Excel 怎样用VBA代码实现自动查找重复行并删除
发布网友
发布时间:2022-04-29 20:28
我来回答
共4个回答
热心网友
时间:2022-06-01 16:50
选定要查找的列,点数据,删除重复项
热心网友
时间:2022-06-01 16:50
以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
热心网友
时间:2022-06-01 16:50
字典 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
热心网友
时间:2022-06-01 16:51
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