CountDuplicates

Counts how many duplicates found in a range of Excel cells.
Basically how many cells that are duplicated in a range of cells in a certain range.
Needs MyRange as Range object to be passed
Helpful was part of some work needed last month
Might needs some work to make it better

CodeFunctionName
What is this?

Public

Tested

Original Work
Function CountDuplicates(MyRange As Range)
    CountDuplicates = 0
    For Each cel In MyRange
        If cel.Row > MyRange.CurrentRegion.Rows.Count Then Exit For
        If WorksheetFunction.CountIf(MyRange, cel.Value) > 1 Then CountDuplicates = CountDuplicates + 1
    Next
End Function

MyRange As Range

Views 836

Downloads 289

CodeID
DB ID