I want to have a threshold value in one cell (A1) and take it as a reference for adding cells. I have over 5000 lines, and more than 10 sheets. Suppose I have: A1 - 10 A2 - 4 A3 - 2 A4 - 3 A5 - 4 A6 - 6 I want to add cells based on A1 (the threshold). If A1 is 10, it would add A2:A5, sum = 13. If A1 is 9, it would add A2:A4, sum = 9. The SUM formula is: =SUM(OFFSET($A$2,0,0,MAX(INDEX((SUBTOTAL(9,OFFSET($A$2, 0,0,ROW(1:5),1))<$A$1)*ROW(1:5),,))+1,1)) But I have a problem when the sum cannot be...