检查是否存在更多输入EXCEL

时间:2014-04-09 12:04:01

标签: excel

我的工作表中有24列和30行。如何检查某些输入是否存在多次以及如何使它们脱颖而出?

1 个答案:

答案 0 :(得分:0)

如果您希望通过更改格式来简单地找到重复的单元格,请运行以下短宏:

Sub DuplicateFinder()
    Dim r As Range, Mesage As String
    Dim rBig As Range
    ActiveSheet.UsedRange
    Set rBig = ActiveSheet.UsedRange
    Mesage = ""
    For Each r In rBig
        If r.Value <> "" Then
            If Application.WorksheetFunction.CountIf(rBig, r) > 1 Then
                Mesage = Mesage & vbCrLf & r.Address(0, 0)
            End If
        End If
    Next r

    If Mesage = "" Then
        MsgBox "no duplicates"
    Else
        MsgBox Mesage
    End If
End Sub