Help with Index Match formula finding last 4 occurences of the name

dangorka

New Member
Joined
Feb 23, 2018
Messages
11
Hi guys,

I have a simple Excel sheet which contains data in two sheets (basically a football league schedule)

Data is contained in column A (home team) and column B (away team for each match)

In column O I manually put the name of the team and formula has to find last four times when following team played a game (no matter if they were home or away team) and match the value from column C from last occurence being listed in cell O2, one before last occurence in cell O3 etc.

I attached the spreadsheet with values which must be found by formula in range O2:O5

https://docs.google.com/spreadsheets/d/1-Waq9s8Xd8bMLxHSuZgkTmkKvq2gXzYtGiVHyoK6FaQ/edit?usp=sharing

Any idea how to achieve that with formulas?
Thanks

Also posted here
https://www.excelforum.com/excel-fo...ast-4-occurences-of-the-name.html#post5197202
 
Last edited by a moderator:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I'm not sure I understand. Your example has
Sochaux
3
14
412
6

...but I would expect
Sochaux
3
14
412
69

Am I misunderstanding?

[TABLE="class: grid, width: 391"]
<tbody>[TR]
[TD]Sochaux[/TD]
[TD]Caen[/TD]
[TD]5[/TD]
[TD]Row=6[/TD]
[/TR]
[TR]
[TD]Paris FC[/TD]
[TD]Sochaux[/TD]
[TD]6[/TD]
[TD]Row=11[/TD]
[/TR]
[TR]
[TD]Sochaux[/TD]
[TD]AJ Auxerre[/TD]
[TD]48[/TD]
[TD]Row=29[/TD]
[/TR]
[TR]
[TD]Lorient[/TD]
[TD]Sochaux[/TD]
[TD]69[/TD]
[TD]Row=35[/TD]
[/TR]
[TR]
[TD]Sochaux[/TD]
[TD]Nancy
[/TD]
[TD]412[/TD]
[TD]Row=41[/TD]
[/TR]
[TR]
[TD]Le Mans[/TD]
[TD]Sochaux[/TD]
[TD]14[/TD]
[TD]Row=52[/TD]
[/TR]
[TR]
[TD]Sochaux[/TD]
[TD]Valenciennes[/TD]
[TD]3[/TD]
[TD]Row=68[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
I struggled with getting the last four if I must check either column A or B for the club name, so I had to add a worker column D.

ABCDLMNO
Chambly FCValenciennes
Rodez AveyronAJ AuxerreSochauxValenciennes
GuingampGrenobleLe MansSochaux
AjaccioLe HavreSochauxNancy
ClermontChateaurouxLorientSochaux
SochauxCaen
NancyOrleans US 45

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"]1[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFF00"]Sochaux[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]4[/TD]

[TD="align: right"][/TD]

[TD="align: center"]3[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]5[/TD]

[TD="align: right"][/TD]

[TD="align: center"]14[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]12[/TD]

[TD="align: right"][/TD]

[TD="align: center"]412[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]4[/TD]

[TD="align: right"][/TD]

[TD="align: center"]69[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"]5[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]

[TD="align: right"]6[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Arkusz1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D1
and
down
[/TH]
[TD="align: left"]=IF(OR(A1=$O$1,B1=$O$1),C1,"")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]M2
and down
[/TH]
[TD="align: left"]=IFERROR(INDEX($A$1:$A$70,AGGREGATE(14,6,ROW($A$1:$A$70)/($D$1:$D$70<>""),ROW()-1)),"")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]N2
and down
[/TH]
[TD="align: left"]=IFERROR(INDEX($B$1:$B$70,AGGREGATE(14,6,ROW($A$1:$A$70)/($D$1:$D$70<>""),ROW()-1)),"")[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]O2
and down
[/TH]
[TD="align: left"]=IFERROR(INDEX($D$1:$D$70,AGGREGATE(14,6,ROW($A$1:$A$70)/($D$1:$D$70<>""),ROW()-1)),"")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
@Toadstool
Just a comment on your column M, N, O formulas: If a user subsequently inserts any new rows at the top of the sheet, those formulas will no longer return the correct results.

@dangorka
Here is a way to get the results directly in O2:O5 without needing a helper column
Note that the yellow in A:B is just so I could easily see where the relevant entries were.
I have hidden some rows to make my post here a bit shorter.

Excel Workbook
ABCO
1Chambly FCValenciennes1Sochaux
2Rodez AveyronAJ Auxerre43
3GuingampGrenoble514
4AjaccioLe Havre12412
5ClermontChateauroux469
6SochauxCaen5
7NancyOrleans US 456
28NancyLorient66
29SochauxAJ Auxerre48
30ClermontLens53
31ValenciennesRodez Aveyron556
32CaenChambly FC63
33GrenobleTroyes41
34ChateaurouxAjaccio14
35LorientSochaux69
36NancyLe Mans67
37Orleans US 45Clermont6
38Paris FCChamois Niortais6
39LensLe Havre67
40AJ AuxerreGuingamp55
41SochauxNancy412
42Le MansLorient53
43AjaccioParis FC97
47Chambly FCChateauroux335
48Rodez AveyronOrleans US 455335
49TroyesLens6
50GuingampValenciennes67
51ChateaurouxTroyes6
52Le MansSochaux14
53CaenLe Havre67
65GuingampNancy1
66AjaccioOrleans US 4524
67Le HavreParis FC55
68SochauxValenciennes3
69ClermontLorient4
70LensChateauroux9
Arkusz1



If you do like the idea of a helper column to keep the formulas a bit simpler, here is a variation of the earlier suggestion (part sheet only shown)

Excel Workbook
ABCDO
1Chambly FCValenciennes1 Sochaux
2Rodez AveyronAJ Auxerre43
3GuingampGrenoble514
4AjaccioLe Havre12412
5ClermontChateauroux469
6SochauxCaen51
7NancyOrleans US 456
8Chamois NiortaisTroyes66
9Le MansLens42
10LorientParis FC45
11Paris FCSochaux62
12Orleans US 45Chambly FC6
Arkusz1 (3)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

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