|
Sub 删除重复行()
Dim i As Integer, r As Integer, j As Integer
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets(Sheets.Count).Delete
Sheets("源").Copy after:=Sheets(Sheets.Count)
With Sheets(Sheets.Count)
r = .Range("A1048576").End(xlUp).Row
For i = 2 To r
.Range("E" & i) = .Range("B" & i) & .Range("C" & i) & .Range("D" & i)
Next
For j = r To 2 Step -1
If Application.CountIf(.Columns(5), .Cells(j, 5)) > 1 Then
.Rows(j).Delete
End If
Next
.Columns(5).Delete
.Columns(1).Delete
.Range("A1").Sort KEY1:=.Range("A1"), order1:=1, KEY2:=.Range("B1"), order2:=1, KEY3:=.Range("C1"), order3:=1, Header:=1
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
请查收,经测试,无误。
|
评分
-
1
查看全部评分
-
|