title: How to perform the sum-group by function in VBA?
body: <p><a href="https://i.stack.imgur.com/3mbsO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3mbsO.png" alt="enter image description here" /></a>
  Here is a table record every staff sales record in every months.</p>
  <p>Every responsible staff in every district could be changed .E.g. District A: May :179 -&gt;June: 220</p>
  <p>Now , i want to sum all staff sales records from May-2016 to Jul-2016 .
  The range should be <code>D3:I21</code>.The range can be hard code.</p>
  <p>Then paste the result on <code>L3:M21</code> .</p>
  <p>The sample output should be</p>
  <blockquote>
  <p>179 1</p>
  <p>186 7</p>
  <p>222 4</p>
  <p>S24 5</p>
  <p>......</p>
  </blockquote>
  <p>How to perform the SQL like <code>select staffid ,sum(total) from table group by staffid</code> in VBA ?</p>
  <h1>Remark :</h1>
  <p>Any idea is okay (no need code) .thank you so much</p>
  <p>Is it able to do it in VBA? Or putting all data into two column in a virtual space .Then do the calculation later?</p>
  <p>I must use VBA because :</p>
  <p>This picture is just a example .Behind the real excel is a user form . The admin can select the fromdate and todate .Then ,generate the report according to the selected range .</p>
  <p>Delete the row 23-Total is okay . Small modifciation of table structure can be considered .</p>