شنبه یازدهم مرداد ۱۳۹۹ - 14:21 - حسين حسين پور -
This code helps you to count the numbers of duplicate values from the selection. When you run this code, it returns a message box which shows the count.
Sub CountDuplicates()
Dim i As Integer
Dim j As Integer
Dim myCell As Range
Dim myRange As Integer
myRange = Range("Table1").Count
j = 0
For Each myCell In Range("Table1")
If WorksheetFunction.CountIf(Range("Table1"), myCell.Value) > 1 Then
j = j + 1
End If
Next
MsgBox j
End Sub
Again in the above code, we have used table name and you change it or replace it with a range.