title: Get a Sum of ONLY duplicate values
body: <p>If there a way to use a sumif combined with a countif?</p>
  
  <p>for example if I have</p>
  
  <pre><code>TransactionNo|NumberToSum
      1        |  
      1        |  9
      2        |  6
      3        |  3
      4        |  
      4        |  4
      5        |  6
      6        |  4
      7        |  
      7        |  9
      8        |  7
      9        |  4
      10       |  
      10       |  1
      11       |  3
      12       |  6
  </code></pre>
  
  <p>My result would be: <strong><em>23</em></strong></p>
  
  <p>because the values <code>1,4,7,10</code> are duplicated, so I need to sum the <code>NumberToSum</code> of those <code>9,4,9,1</code> in this case.</p>
  
  <p>Ideally I would like somethings along the lines of <code>=SumIf(A:A,Count&gt;1,B:B)</code> </p>
  
  <p>Where B is summed if the count of A inside of A:A is > 1.</p>
  
  <p>but <code>=SUMIF(A:A,COUNT(A:A)&gt;1,B:B)</code> does not work.</p>
  
  <p><em><strong>NOTE:</em></strong> the Data is <em>NOT</em> sorted as it appears in my example. </p>
  
  <p>If I wanted to do it in VBA one quick way could be: </p>
  
  <pre><code>Sub sumdups()
  Dim rng As Range
  Dim rng2 As Range
  Dim Sum As Long
  
  Set rng = [A2:A17]
  
  For Each rng2 In rng
      If WorksheetFunction.CountIf(Range("A1:A17"), rng2.Value) &gt; 1 Then
          Sum = Sum + rng2.Offset(0, 1).Value
      End If
  Next rng2
  End Sub
  </code></pre>
  
  <p>Another option I have tried is to add a column with the formula </p>
  
  <pre><code> =IF(COUNTIF(A:A,A2)&gt;1,B2,"")
  </code></pre>
  
  <p>Then sum the helper column, but I am hoping there is a simple formula that can do the same all in one cell. </p>
  
  <p>I am really just looking for a faster formula that can be entered in a single cell, without the need for any additional calculations.</p>