ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   summing first 'n' values in a column or row (https://www.excelbanter.com/excel-worksheet-functions/157310-summing-first-n-values-column-row.html)

Fran McConville

summing first 'n' values in a column or row
 
I'd simply like to sum the first n values in a column or row, where the value
of n is in a separate cell. ie if I enter '3', it will sum only the first
three values in the range, if I enter '8' it will return the sum of the first
8 values in the range. TIA for any help

ExcelBanter AI

Answer: summing first 'n' values in a column or row
 
Steps to sum the first 'n' values in a column or row, where 'n' is in a separate cell:
  1. Select the cell where you want the sum to appear.
  2. Type the following formula into the formula bar:
    Formula:

    =SUM(A1:INDEX(A1:A100B1)) 

    - In this formula, A1 is the first cell in the range you want to sum.
    - A100 is the last cell in the range you want to sum.
    - B1 is the cell where you will enter the value of 'n'.
  3. Press Enter to calculate the sum.

Here's how the formula works:

- The INDEX function returns a reference to a cell based on a specified row and column number. In this case, we're using it to return a reference to the 'n'th cell in the range.
- The 'n' value is entered in cell B1, so we're using that cell reference in the INDEX function.
- The SUM function then adds up all the values from the first cell in the range (A1) up to the 'n'th cell in the range (which is determined by the INDEX function).

So, if you enter '3' in cell B1, the formula will sum the first three values in the range A1:A3. If you enter '8' in cell B1, the formula will sum the first eight values in the range A1:A8.

Peo Sjoblom

summing first 'n' values in a column or row
 
=SUM(A1:INDEX(A1:A10000,D1))

change any cell references accordingly to fit your own requirements

--
Regards,

Peo Sjoblom




"Fran McConville" wrote in
message ...
I'd simply like to sum the first n values in a column or row, where the
value
of n is in a separate cell. ie if I enter '3', it will sum only the first
three values in the range, if I enter '8' it will return the sum of the
first
8 values in the range. TIA for any help




Domenic

summing first 'n' values in a column or row
 
Assuming that A2:A100 contains the data, and C2 contains n, try...

=SUM(A2:INDEX(A2:A100,C2))

Hope this helps!

In article ,
Fran McConville wrote:

I'd simply like to sum the first n values in a column or row, where the value
of n is in a separate cell. ie if I enter '3', it will sum only the first
three values in the range, if I enter '8' it will return the sum of the first
8 values in the range. TIA for any help


Chip Pearson

summing first 'n' values in a column or row
 
Fran,

To sum the first N rows of a column, use

=SUM(OFFSET(A1,0,0,B2,1))

Where A1 is the first cell to sum and B2 contains the number of cells.

To sum the first N columns of a row, use

=SUM(OFFSET(A1,0,0,1,B2))

Where A1 is the first cell to sum and B2 contains the number of cells.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Fran McConville" wrote in
message ...
I'd simply like to sum the first n values in a column or row, where the
value
of n is in a separate cell. ie if I enter '3', it will sum only the first
three values in the range, if I enter '8' it will return the sum of the
first
8 values in the range. TIA for any help



Fran McConville

summing first 'n' values in a column or row
 
Thanks folks! You're all geniuses!


All times are GMT +1. The time now is 06:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com