Sub yy()
Dim n%, i%, ci%, c As Range
n = [a65536].End(xlUp).Row
For i = 2 To n
If Application.CountIf(Range("a2:b" & n), Cells(i, 1)) > 1 Then
If c Is Nothing Then
Set c = Rows(i)
ci = 1
Else
Set c = Union(c, Rows(i))
ci = ci + 1
End If
End If
Next i
c.Copy Sheet2.[a1]
With Sheet2
.Range("A1:b" & ci).Sort Key1:=.Range("a1")
End With
End Sub作者: luhpro 時間: 2015-1-1 09:07