excel筛选重复项代码

Sub test()
'updateby Extendoffice 20151030
    Dim xRng As Range
    Dim xTxt As String
    On Error Resume Next
    xTxt = Application.ActiveWindow.RangeSelection.Address
    Sheets("Data").Select
    Columns("A:W").Select
    Set xRng = Columns("A:W")
    If xRng Is Nothing Then Exit Sub
    If (xRng.Columns.Count < 2) Or (xRng.Rows.Count < 2) Then
        MsgBox "the used range is invalid", , "Kutools for Excel"
        Exit Sub
    End If
    xRng.Sort key1:=xRng.Cells(1, 22), Order1:=xlAscending, key2:=xRng.Cells(1, 23), Order2:=xlDescending, header:=xlGuess
    xRng.RemoveDuplicates Columns:=1, header:=xlGuess
End Sub




--COUNTIF函数
=IF(COUNTIF(A$2:A59,A59)>1,"重复","")

你可能感兴趣的:(excel筛选重复项代码)