|
发表于 2014-3-19 13:52
|
显示全部楼层
本楼为最佳答案
- Sub Macro1()
- Dim arr, rng As Range, d, i&, x%, p$
- Application.ScreenUpdating = False
- Application.StatusBar = "正在删除中……"
- Set d = CreateObject("scripting.dictionary")
- '第一步删除空行
- arr = ActiveSheet.UsedRange
- x = UBound(arr, 2)
- For i = 1 To UBound(arr)
- If Application.CountA(Cells(i, 1).Resize(1, x)) = 0 Then
- If rng Is Nothing Then Set rng = Cells(i, 1) Else Set rng = Union(rng, Cells(i, 1))
- End If
- Next
- If Not rng Is Nothing Then rng.EntireRow.Delete
- Set rng = Nothing
- '第二步删除重复行
- arr = ActiveSheet.UsedRange
- For i = 1 To UBound(arr)
- p = Join(Application.Index(arr, i, 0), ",")
- If Not d.exists(p) Then
- d(p) = i
- Else
- If rng Is Nothing Then Set rng = Cells(i, 1) Else Set rng = Union(rng, Cells(i, 1))
- End If
- Next
- If Not rng Is Nothing Then rng.EntireRow.Delete
- Application.StatusBar = "删除完毕,OK"
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
查看全部评分
|