title: set sum formula in excel using vba
body: <p>Working on a excel macros where I am trying to add the cell values from above cells to calculate total value. This is what my data looks like<img src="https://i.stack.imgur.com/uyKrz.png" alt="Sample Excel Document"></p>
  
  <p>Here I want to add above cell values for each column to calculate the sum. To accomplish this i have written a macro as follows. </p>
  
  <pre><code>For cl = 2 To 5    
      Worksheets(5).Cells(4, cl).Formula = "=SUM(B4:B6)"        
  Next cl
  </code></pre>
  
  <p>This should set the formula to each cell in a row till 5 columns.
  But it sets the same formula on all cells in a row it should get change according to column. How to set sum formula for each cell for corresponding column ?</p>