title: Excel formula to sum values based on reference number in another column
body: <p>I have two columns. One is an amount and the other is a reference number. I need a formula to sum all amounts per reference number next to the reference number in order to sort from highest to lowest value per reference.</p>
  
  <pre><code>Amount | Reference | Sum per Reference
  122.00 |   405221  |     316
  194.00 |   405221  |     316
  339.80 |   405682  |     851.25
  296.45 |   405682  |     851.25
  215.00 |   405682  |     851.25
  </code></pre>
  
  <p>The closest formula I found on this website, was:</p>
  
  <pre><code>=IF((AR2=AR3),"",SUM($AQ2:AQ2-SUM(AV$1:AV1)))
  </code></pre>
  
  <p>This however only puts the sum value (like a subtotal) at the last reference number and leaves the other ones blank. I need it to put the sum value for each reference number next to all the lines and have not blank spaces?</p>