发布网友 发布时间:2022-04-29 20:28
共1个回答
热心网友 时间:2022-06-22 10:00
vba去除重复项,可以考虑使用字典
Sub 按钮1_Click()
Set d = CreateObject("scripting.dictionary")
Set Rng = Nothing
arr = [a1].CurrentRegion
Application.ScreenUpdating = False
For j = 1 To UBound(arr)
If d.exists(arr(j, 1)) Then
If Rng Is Nothing Then
Set Rng = Cells(j, 1)
Else
Set Rng = Union(Rng, Cells(j, 1))
End If
Else
d(arr(j, 1)) = ""
End If
Next j
If Not Rng Is Nothing Then Rng.EntireRow.Delete
Application.ScreenUpdating = True
End Sub