title: Excel VBA Loop through table and sum up values
body: <p>I have this table about 50,000 rows long that I would like Excel to go through and assign a number or letter.</p>
  
  <p>Basically I am trying to group rows of data based on their sum being greater than 1,000,000.</p>
  
  <p>If cell A in that row is less than 1,000,000 it will go to the next row and add up the previous cell A to the current one, and so on. This continues until the sum of all rows >= 1,000,000. When that happens, a number is "assigned" (as in entered at the end of the rows).</p>
  
  <p>Sample data:</p>
  
  <p><img src="https://i.stack.imgur.com/EKsN7.jpg" alt="Table example"></p>
  
  <p>Here is my current "pseudo" code:</p>
  
  <pre><code>For x = 2 to lastrow
      y = 1
  
      If Range("A" &amp; x).value &lt; 1000000 Then
  
  'I know something needs to be entered here but I don't know what
  
          Do while balance &lt; 1000000
  
              sumbalance = Range("A" &amp; x) + Range("A" &amp; x + 1)
  
  'Until sumbalance &gt;= 1000000 Then Range("A" &amp; x).Offset(0, 2).value = y
  
       Else
  
           Range("A" &amp; x).offset(0, 2).value = y + 1 '(?)         
  
  Next x
  </code></pre>
  
  <p>Can someone point me the in the right direction?</p>