title: Sum of unfixed number of cells if corresponding cell has given value
body: <p>I am strugling how to make this happen. I have a worksheet where the data is going to be read in. The size of the data will vary from time to time. I have programmed a generated summation column after the data is read in. I want each cell to sum all values in the row, with the index value in the first row equal to the value in the first row in the summation column. The picture might give you a less abstract visualization of the case. I included the manual formulas for row 3 in row 12 as text. I want to do this in VBA. There might be up to 50 sets ([2010,2011,avvik] or [2010,avvik] or [2011,avvik]). There are two variables with a saved number (column number) for both the start and the end of the data area.</p>
  <p>In other words; The money column under &quot;SUM 2010&quot; (which in my program actually is only 2010) should sum every cell in the given row, which has the value 2010 in row 1 in the same column. The same goes for 2011.</p>
  <p><img src="https://i.stack.imgur.com/ZIabk.jpg" alt="Example" /></p>
  <p>(You might want to save/open the picture for details)</p>