title: How to sum columns for a selected range using VBA?
body: <p>After I have selected a range containing numerical values, I want to, via VBA, input a <code>=SUM</code> formula at the bottom of each column, i.e. on the row after the last selected row. For each column it should sum all of the values in the corresponding column of the entire selection. </p>
  
  <p>How can I do this?</p>
  
  <p>Right now, I am using the code given by the macro recorder: <code>ActiveCell.FormulaR1C1 = "=SUM(R[-10]C:R[-1]C)"</code>. The problem is when my range gets bigger than 10 rows it will not take the rows above the bottom 10 into consideration.  </p>
  
  <p><img src="https://i.stack.imgur.com/qv2UK.png" alt="enter image description here"></p>