title: stop excel do-loop until
body: <p>I have two columns A and B with numbers as values. </p>
  
  <ul>
  <li>In C1 I want <code>=A1 + B1</code></li>
  <li>In C2 I want <code>=A2 + B2</code></li>
  </ul>
  
  <p>and so on. I have written the following VBA code - while it works it adds "0" after the end of the last row in range.</p>
  
  <p>Let's assume my last row is A10. It adds "0" in C11 when I run the code.
  How do I prevent this?</p>
  
  <pre><code>Sub macro()
  
  Dim R As Long
  R = 1
  Do
  Cells(R, "C").Select
  R = R + 1
  ActiveCell.Formula = "=sum(" &amp; ActiveCell.Offset(0, -2) &amp; "," &amp; 
  ActiveCell.Offset(0, -1)    &amp; ")"
  Loop Until IsEmpty(ActiveCell.Offset(0, -2))
  
  End Sub
  </code></pre>