ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How to sum a variable number of items (https://www.excelbanter.com/excel-worksheet-functions/189361-how-sum-variable-number-items.html)

RobinC

How to sum a variable number of items
 
How do I sum the first X cells in a list where X is defined in another cell?

Specifically, I have a list of numbers in cells B4:B30.

In cell A1, I have another number, which I want to be able to change around.
So that if A1=4, then I sum B4:B8, but if A1=5, then I sum B4:B9 and so on.

Peo Sjoblom

How to sum a variable number of items
 
One way

=SUM(B4:INDEX(B4:B30,A1))


--


Regards,


Peo Sjoblom



"RobinC" wrote in message
...
How do I sum the first X cells in a list where X is defined in another
cell?

Specifically, I have a list of numbers in cells B4:B30.

In cell A1, I have another number, which I want to be able to change
around.
So that if A1=4, then I sum B4:B8, but if A1=5, then I sum B4:B9 and so
on.




Stefi

How to sum a variable number of items
 
=SUM(OFFSET(B4,0,0,A1,1))

Regards,
Stefi

€˛RobinC€¯ ezt Ć*rta:

How do I sum the first X cells in a list where X is defined in another cell?

Specifically, I have a list of numbers in cells B4:B30.

In cell A1, I have another number, which I want to be able to change around.
So that if A1=4, then I sum B4:B8, but if A1=5, then I sum B4:B9 and so on.



All times are GMT +1. The time now is 03:41 AM.

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