title: excel count/sum stop count/sum match?
body: <p>I have tried to see if this question has been asked before, but I can't seem to find an answer.</p>
  
  <p>I have a column of cells (>3000 rows), with either a value of 1 or 0 (call this column A). The value will depend on the value in column B (which will contain either a value or nothing). The values in column B are a SUMIFS function based, summing from column C, and based on months in column D. </p>
  
  <p>The values in B are paid out on the first business day of the next month. So, the SUMIFS function will calculate the dates that match the last month. This works well in theory, however, not every first business day is the first day of the month. This leads the SUMIFS function to not include everything in the correct month, and allows for some discrepancy, which, when you are dealing with people's money is not great. Further, this discrepancy is compounded across multiple periods (in some cases, there are over 100 periods, and a discrepancy of $1 in period 1 amounts to nearly $1000 in period 100)</p>
  
  <p>What I am wondering is:</p>
  
  <p>Is there any way that I can tell the SUMIFS function (column B) to stop when the value in column A is 0? This would tell the SUM function start the summing from the current value in column B and continue the function to the cell below the preceding value in column B.</p>
  
  <p>I've seen suggestions that the MATCH function may work, but I can't see how to do this with either COUNT or SUM.</p>
  
  <p>For security reasons, this solution needs to be entered into the cell, and can't be VBA. Also, it can't be too large, as it will need to be replicated across 200 worksheets in the workbook (not my file originally, and I would have done it differently, but that is another story). There is no problem entering another column or two if that is required.</p>
  
  <p>Any help is gratefully appreciated.</p>
  
  <p>EDIT:</p>
  
  <p>Unfortunately, I can't post an image of the screenshot. I've included a similar screenshot (columns are not the same layout, but hopefully it gives the idea) here:</p>
  
  <p><a href="https://www.dropbox.com/s/ij35zwmawshlv7t/mil.jpg?dl=0" rel="nofollow">Rates calculations</a></p>
  
  <p>The SUMIF formula is (for B2)</p>
  
  <p>=SUMIFS(C2:C35,D2:D35,D2-1,A2:A35,1)</p>
  
  <p>This works fine if I want all the values in the month, irrelevant of when the payment was made.</p>
  
  <p>However, what I need the formula to do is:</p>
  
  <p>SUM (C2:C35,D2:D35,D2-1, but stop when the first 0 is encountered in A2:A35)</p>
  
  <p>Thanks</p>