Variable sum

allene

New Member
Joined
Apr 1, 2002
Messages
1
I want to sum up a range of cells but have the number of cells be a variable defined by another cell. It would be nice if the following worked, for example
=sum(b18:b(18-a18)), but it doesn't. This would sum up all the cells from b18 back for a18 cells
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
=SUM(B18:INDIRECT("B"&18-A18))

or

=SUM(B18:OFFSET(B18,-A18,))
This message was edited by Mark W. on 2002-04-02 09:48
 
Upvote 0
If you want to sum the number of cells in cell A18, then you will need to add one:

=SUM(B18:INDIRECT("B"&18-A18+1))

For example: you have 4 in cell A18, and you want to sum only the last 4 cells. 18-4=14, but the range B18:B14 is actually 5 cells (14,15,16,17,18).

HTH,

Russell
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,812
Members
449,048
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top