ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Can I use a value to set the range of a SUM (i.e. SUM cell B5 and. (https://www.excelbanter.com/excel-discussion-misc-queries/13670-can-i-use-value-set-range-sum-i-e-sum-cell-b5.html)

Dynamic Sum Ranger

Can I use a value to set the range of a SUM (i.e. SUM cell B5 and.
 
My variable is "# of weeks" and if I set it to "6", I want the formula to sum
the values from cell B5 down 6 entries. Or if I set it to "5", I want it to
sum the values from B5 down 5 entries....etc...



Peo Sjoblom

Assume the variable is in cell A1

=SUM($B$5:INDEX($B$5:$B$1000,A1))

it's better to use index instead of offset or indirect since it is not
volatile


--

Regards,

Peo Sjoblom

"Dynamic Sum Ranger" <Dynamic Sum wrote in
message ...
My variable is "# of weeks" and if I set it to "6", I want the formula to

sum
the values from cell B5 down 6 entries. Or if I set it to "5", I want it

to
sum the values from B5 down 5 entries....etc...






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

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