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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
=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,817
Members
449,049
Latest member
cybersurfer5000

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