title: Add total to column where row header meets criteria
body: <p>Apologies beforehand for this, I'm very new to VBA and I'm sure this is simple coding that I'm struggling with. </p>
  
  <p>Based on a user defined number of months (just entered into the ssheet) I have a row of column headings giving the month number and the heading "Total" after the last month. </p>
  
  <p>i.e. User says 12 months, cell A2 = "Jan-15" and M2 = "Total". </p>
  
  <p>Underneath the headings the user then adds some sales data.</p>
  
  <p>What I need to do is use VBA to add a total to the end of each of the rows of data where the header = "total". </p>
  
  <p>I was thinking an If Then makes sense but I'm struggling with how to get the macro to put the formula in the correct cell and then have the formula look at the variable range. This is the best I've come up with so far (please don't laugh!)</p>
  
  <pre><code>Sub Add_total()
  Dim criteria As String
  criteria = Range("A:A").Value
  If criteria = "Total" Then
  Range("12:12").Select
  ActiveCell.Formula = "=sum($c12:c12)"
  End If
  End Sub
  </code></pre>
  
  <p>What I'd like is, for example, where M2 = "Total", then C12 = sum(c1:L12)</p>
  
  <p>I realise the easiest way would be to just get the user to add the total themselves or have a total column far away to the left of the sheet but this is going across the business and needs to restrict manual input/guarantee accuracy of the calcs. </p>
  
  <p>Any help much appreciated. </p>