# Thread: Sum first number "n" values

1. Hi,

I'm trying to figure out the formula to sum the first "n" values in a table. The "n" value is the number of rows that will be equal to the value in cell C1 minus 1 row (see attached spreadsheet). I think you need to use the index function here to figure out the "n" value, but I have no idea how.

Thanks.

2. Do really mean sum all the values in C IF the value in A is < the value in C1 ?

That appears to be what the calculation you have in there is attempting to do.

If that is the case then

=SUMIF(\$A\$6:\$A\$37,"<" & \$C\$1,\$C\$6:\$C\$37)

[attachment=88297:Sum_to_Value.xls]

3. I'm not clear on your question - does =SUMIF(\$A\$6:\$A\$37,"<"&C1,\$C\$6:\$C\$37) do what you want?

4. Great, this is what I wanted. I can't believe the equation is this simple. I'm so glad that this forum exists. Thanks all!

Just for interest sake, I was sure that the same could have been achieved using the 'INDEX' and 'MATCH' functions to get the "to" cell address so that the summation equation would have been '=sum(A6:A#)', where"#" corresponds to a row number of a value not greater than the value in C1. Anyone knows the full function for this?

5. Something like this perhaps?
Steve

=SUM(OFFSET(C5,0,0,MATCH(C1,A6:A37),1))

6. Works great. Thanks.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•