title: Finding and counting number of duplicates
body: <p>I have a spreadsheet with a column called NumberID that has about 50k records. I am aware that there are duplicates however with scrolling up/down it takes forever to find anything plus often times excel is being somewhat slow. I'm trying to write a quick snippet of code to be able to find and count the number of duplicates. </p>
  
  <p>I'm trying to write a quick way of doing it, basically my data is from rows 20 to 48210 and I'm trying to find a number total duplicate records.</p>
  
  <pre><code>Dim lastRow As Long
  Dim matchFoundIndex As Long
  Dim iCntr As Long
  Dim count As Long
  count = 0
  lastRow = Range("B48210").End(xlUp).Row
  For iCntr = 1 To lastRow
      If Cells(iCntr, 1) &lt;&gt; "" Then
         matchFoundIndex = WorksheetFunction.Match(Cells(iCntr, 1), Range("B20:B" &amp; lastRow), 0)
          If iCntr &lt;&gt; matchFoundIndex Then
              count = count + 1
          End If
       End If
  Next
  
  MsgBox count
  </code></pre>
  
  <p>Here im getting an error on = WorkSheetFunction.Match - i found that this property can be used to accomplish what I'm trying to do. The error says </p>
  
  <blockquote>
    <p>Unable to get the match property for the worksheetfunction class.</p>
  </blockquote>
  
  <p>Someone have an idea? My vba has been rusty</p>