title: Dynamic excel sum function
body: <p>I am trying to make a sum formula on a dynamic range. Much like in a pivot table.</p>
  
  <p>Taking a look on the picture I want <strong>L15</strong> to be the sum of the range from L16 to the blank row. As the range is dynamic I am not sure how to write it on my code. So far what I have is this:</p>
  
  <pre><code>If out.Range("A15").Cells(i, 1) = "Aktier" Then
          out.Range("L15").Cells(i, 1) = Application.WorksheetFunction.Sum(Range("L15").Cells(i + 1, 1), Range("L15").Cells(i + 1, 1).End(xlDown))
  End If
  </code></pre>
  
  <p>So my question is basically how do I write something like Sum(A1:End(xlDown))? :)</p>
  
  <p>Hope you can help me out guys! :D </p>
  
  <p>Thanks in advance!</p>
  
  <p><a href="https://i.stack.imgur.com/R2B5t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R2B5t.png" alt="Data picture"></a></p>