title: Consolidation of dynamically changing data in VBA
body: <p>I work with data including unique names of customers and values of their purchases. I want to conduct its consolidation, meaning the result would be customers and their total sums of purchase like in the picture below:</p>
  <p><a href="https://i.stack.imgur.com/aWiVO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aWiVO.png" alt="enter image description here" /></a></p>
  <p>The data is changing after every VBA code operation (new customers come in, old disappear, new transactions are recorded etc.) which somehow leads to this line of code generating errors:</p>
  <pre><code>Sheets(&quot;Sheet1&quot;).Range(D2).Consolidate Sources:=Array(Sheet1!R2C1:R3C51), Function:=xlSum
  </code></pre>
  <p>Is there a different approach to this situation so that there's no problem with getting the right results?</p>