Sum of last "x" values across columns

Space_Cowboy

New Member
Joined
Oct 12, 2017
Messages
6
Please see below. Row 3 is the header row. data contained in (b3:c12). I am looking for a way to automatically look for the last 12 populated cells in (b3:c12), and place the result in d13. for example, in the below sample data, d13 should sum (C4:C9)+(B7:B12) for a value of 71. When I later add data to cell c10, I need for d13 to now sum (C4:C10)+(b8:b12), and so on. When the data is down to d12, the next data value will be in d4 and the calculation in d13 will appear in e13. Is therre a way to do this?


bcd
320162017
454
534
645
727
8912
9112
104
118
123
13ddd
14
15
26

<tbody>
</tbody>
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Re: Sum of last "x" values avross columns

It looks like you want to sum the most recent 12 months' values, but there are only 9 rows of data for each month.

Is that right? Which means that when you have one value for 2018, you'll be summing:

- that one value for 2018, plus
- all 9 values for 2017, plus
- the last two values for 2016?
 
Upvote 0
Re: Sum of last "x" values avross columns

My mistake in the table. There will never be more than 2 columns used. So in June of 2018 for instance, I want to pull Jan through Jun of 2018 and also July through December of 2017.
 
Upvote 0
Re: Sum of last "x" values avross columns

C19: =SUMPRODUCT(MyData*(DATE(Years,Months,1)<=RequiredDate)*(DATE(Years,Months,1)>=1+EDATE(RequiredDate,-N)))

where:

RequiredDate: = C17 (entered as a date, not text)
n: = C18
MyData: =C4:E15
Years: =C3:E3
Months: =B4:B15


Excel 2010
BCDE
3Month201620172018
4154
5234
6345
7427
85912
96112
1074
1188
1293
13106
14117
151211
16
17Sum toJun 2017
18No months12
19Result83
Sheet1
 
Last edited:
Upvote 0
Re: Sum of last "x" values avross columns

... I am looking for a way to automatically look for the last 12 populated cells in (b3:c12)...
... There will never be more than 2 columns used. So in June of 2018 for instance, I want to pull Jan through Jun of 2018 and also July through December of 2017.
If your 2-year, 12-month monthly data reside in range B4:C15 and if there are no unpopulated cells before the latest entry, then try:

=SUM(C4:C15)+SUMIF(C4:C15,"",B4:B15)
 
Upvote 0

Forum statistics

Threads
1,215,898
Messages
6,127,632
Members
449,391
Latest member
Kersh82

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