如下图输入代码 3、代码 Sub 按钮1_Click() Application.ScreenUpdating = False '关闭刷屏 arr = [a1].CurrentRegion '将数据读入数组,提升读取效率 Set Rng = Nothing 'rng为了保存重复项 Set d = CreateObject(scripting.dictionary) '设置字典变量,用于去重 For J = 2 To UBound(arr) '循环遍历,查找重复项 If d.exists(arr(J, 1)) Then '根据字典里是否有该值,来确定是否有重复 If Rng Is Nothing Then '将重复项,使用union函数,赋值给变量rng Set Rng = Cells(J, 1).Resize(1, 2) Else Set Rng = Union(Rng, Cells(J, 1).Resize(1, 2)) End If Else d(arr(J, 1)) = End If Next J If Not Rng Is Nothing Then Rng.Delete '如果有重复。即删除 Application.ScreenUpdating = TrueEnd Sub4、代码运行后实现效果截图