title: Excel VBA formula with a variable
body: <p>I have a code that is hard coded for a range, I'd like it to be universal. I have a Variable called "LastLine" which works well for when I'm setting a range to set a formula IE:</p>
  
  <pre><code>Range("A1:A" &amp; Lastline).FormulaR1C1 = "..."
  </code></pre>
  
  <p>but When I try to use it in the formula itself I'm doing something wrong</p>
  
  <pre><code>Range("H2").FormulaR1C1 = "=sum(R3C8:R &amp; Lastline &amp; C8)"
  </code></pre>
  
  <p>can someone explain how I'm doing this wrong and if so is there a better way of doing this?</p>