Sumif but only last 6 occurrences

SHARPY1

Board Regular
Joined
Oct 1, 2007
Messages
183
I have this sumif function,
but this will sum about 50 occurrences of data in E329,
how do i adapt formula to just sumif last 6 occurrences??

=SUMIF(E2:E328,E329,I2:I328)

Any help appreciated
Cheers
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
My request is very similar to others in this thread. I have five columns with Date, Home Team, Away Team, Home Goals, Away Goals, and I wish to sum the last six occurrences of Team x - regardless of whether it is the Home Team or the Away Team. Therefore I wish to sum for example, Crystal Palace goals scored whether they played at home or away.

DateHomeTeamAwayTeamFTHGFTAG
05/03/2018Crystal PalaceMan United23
04/03/2018BrightonArsenal21
04/03/2018Man CityChelsea10
03/03/2018BurnleyEverton21
03/03/2018LeicesterBournemouth11
03/03/2018LiverpoolNewcastle20
03/03/2018SouthamptonStoke00
03/03/2018SwanseaWest Ham41
03/03/2018TottenhamHuddersfield20
03/03/2018WatfordWest Brom10
01/03/2018ArsenalMan City03
25/02/2018Crystal PalaceTottenham01
25/02/2018Man UnitedChelsea21
24/02/2018BournemouthNewcastle22
24/02/2018BrightonSwansea41
24/02/2018BurnleySouthampton11
24/02/2018LeicesterStoke11
24/02/2018LiverpoolWest Ham41
24/02/2018WatfordEverton10
24/02/2018West BromHuddersfield12
12/02/2018ChelseaWest Brom30
11/02/2018HuddersfieldBournemouth41
11/02/2018NewcastleMan United10
11/02/2018SouthamptonLiverpool02
10/02/2018EvertonCrystal Palace31
10/02/2018Man CityLeicester51
10/02/2018StokeBrighton11
10/02/2018SwanseaBurnley10
10/02/2018TottenhamArsenal10
10/02/2018West HamWatford20
05/02/2018WatfordChelsea41
04/02/2018Crystal PalaceNewcastle11
04/02/2018LiverpoolTottenham22
03/02/2018ArsenalEverton51
03/02/2018BournemouthStoke21
03/02/2018BrightonWest Ham31
03/02/2018BurnleyMan City11
03/02/2018LeicesterSwansea11
03/02/2018Man UnitedHuddersfield20
03/02/2018West BromSouthampton23
31/01/2018ChelseaBournemouth03
31/01/2018EvertonLeicester21
31/01/2018Man CityWest Brom30
31/01/2018NewcastleBurnley11
31/01/2018SouthamptonBrighton11

<colgroup><col style="mso-width-source:userset;mso-width-alt:2742;width:56pt" width="75"> <col style="width:48pt" span="4" width="64"> </colgroup><tbody>
</tbody>
I've tried the suggested formulas earlier in the thread but i'm not succeeding. Help please.
 
Upvote 0
Thanks for your prompt reply Aladin. However, I am getting a #NUM error with your solution. I have changed the column references as in my sheet I have Column C = Home Team, Column D= Away Team, Column E = Home Goals, Column F= Away Goals. I have Liverpool (or any other team) in K3 and 6 in K2. Perhaps you would be good enough to alter as per my above, but also explain certain parts of your formula. I am particularly confused over the first part where you have =SUM(IF(ROW(............. but use a column ($A$2:$A$46). I don't have many brain cells available for Excel formulas and those I have are confused,
 
Upvote 0
Thanks for your prompt reply Aladin. However, I am getting a #NUM error with your solution. I have changed the column references as in my sheet I have Column C = Home Team, Column D= Away Team, Column E = Home Goals, Column F= Away Goals. I have Liverpool (or any other team) in K3 and 6 in K2. Perhaps you would be good enough to alter as per my above, but also explain certain parts of your formula. I am particularly confused over the first part where you have =SUM(IF(ROW(............. but use a column ($A$2:$A$46). I don't have many brain cells available for Excel formulas and those I have are confused,

Here is the workbook you can adjust to your own layout: https://www.dropbox.com/s/i4ehoiwhsqmdplv/DeeEmmEss%20only%20last%206%20occurrences.xlsx?dl=0
 
Upvote 0
Hi!

Try the formula below too:

=SUMPRODUCT((ROW($2:$46)>=LARGE(($C$2:$D$46=$K$3)*ROW($2:$46),
MIN(COUNT(INDEX(FIND(" "&$K$3&" "," "&$C$2:$D$46&" "),)),$K$2)))*($C$2:$D$46=$K$3)*$E$2:$F$46)


Markmzz
 
Upvote 0
Thankyou so much for your help Aladin, working perfectly now. Thanks also to Markmzz for taking the time to help - thankyou.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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