widgewilliams
New Member
- Joined
- Apr 11, 2017
- Messages
- 16
@widgewilliams
This thread is old and getting very big - difficult to locate the formula you are referring to and the corresponding data.
I suggest you create a new thread by showing us a small sample of your data along with expected results.
To post a sample of your data see section B in
https://www.mrexcel.com/forum/board-announcements/127080-guidelines-forum-use.html
Then, if you wish, you can put a link here to the new thread.
M.
As requested I've started a new post for this question.
In one worksheet "Historical Data" I have a table A1:BV1825. The data in that table is 5 years worth or English Premier League Results and is constantly being added to. Columns B through J are the ones of interest for this question.
<tbody>
[TD="class: xl65"][/TD]
[TD="class: xl65, width: 64"]B[/TD]
[TD="class: xl65, width: 64"]C[/TD]
[TD="class: xl65, width: 64"]D[/TD]
[TD="class: xl65, width: 64"]E[/TD]
[TD="class: xl65, width: 64"]F[/TD]
[TD="class: xl65, width: 64"]G[/TD]
[TD="class: xl65, width: 64"]H[/TD]
[TD="class: xl65, width: 64"]I[/TD]
[TD="class: xl65, width: 64"]J[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]Date[/TD]
[TD="class: xl65"]HomeTeam[/TD]
[TD="class: xl65"]AwayTeam[/TD]
[TD="class: xl65"]FTHG[/TD]
[TD="class: xl65"]FTAG[/TD]
[TD="class: xl65"]FTR[/TD]
[TD="class: xl65"]HTHG[/TD]
[TD="class: xl65"]HTAG[/TD]
[TD="class: xl65"]HTR[/TD]
[TD="class: xl65"]3[/TD]
[TD="class: xl65"]18/08/12[/TD]
[TD="class: xl65"]Arsenal[/TD]
[TD="class: xl65"]Sunderland[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl65"]4[/TD]
[TD="class: xl65"]18/08/12[/TD]
[TD="class: xl65"]Fulham[/TD]
[TD="class: xl65"]Norwich[/TD]
[TD="class: xl65"]5[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]5[/TD]
[TD="class: xl65"]18/08/12[/TD]
[TD="class: xl65"]Newcastle[/TD]
[TD="class: xl65"]Tottenham[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl65"]6[/TD]
[TD="class: xl65"]18/08/12[/TD]
[TD="class: xl65"]QPR[/TD]
[TD="class: xl65"]Swansea[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]5[/TD]
[TD="class: xl65"]A[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]A[/TD]
[TD="class: xl65"]7[/TD]
[TD="class: xl65"]18/08/12[/TD]
[TD="class: xl65"]Reading[/TD]
[TD="class: xl65"]Stoke[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]A[/TD]
[TD="class: xl65"]8[/TD]
[TD="class: xl65"]18/08/12[/TD]
[TD="class: xl65"]West Brom[/TD]
[TD="class: xl65"]Liverpool[/TD]
[TD="class: xl65"]3[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]9[/TD]
[TD="class: xl65"]18/08/12[/TD]
[TD="class: xl65"]West Ham[/TD]
[TD="class: xl65"]Aston Villa[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]10[/TD]
[TD="class: xl65"]19/08/12[/TD]
[TD="class: xl65"]Man City[/TD]
[TD="class: xl65"]Southampton[/TD]
[TD="class: xl65"]3[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
</tbody>
Each week new rows are added to the bottom of the table as the football seasons progress. Currently the last row is 1825.
<tbody>
[TD="class: xl65"]1825[/TD]
[TD="class: xl66, width: 64"]5/4/2017[/TD]
[TD="class: xl65, width: 64"]Swansea[/TD]
[TD="class: xl65, width: 64"]Tottenham[/TD]
[TD="class: xl65, width: 64"]1[/TD]
[TD="class: xl65, width: 64"]3[/TD]
[TD="class: xl65, width: 64"]A[/TD]
[TD="class: xl65, width: 64"]1[/TD]
[TD="class: xl65, width: 64"]0[/TD]
[TD="class: xl65, width: 64"]H[/TD]
</tbody>
In a seperate worksheet "Output" I have a Drop Down List containing the names of each team in the English Premiership.
By selecting any particular team in the drop down list I am looking to pull a range of statistics for that team and display them in the Output worksheet.
One of those sets of statistics is the Current Form of the team over their last 12 games - both home and away.
What I (think) I need to be able to do is to look up columns C and D in the "Historical Data" worksheet to find matches to the drop down box Output!$B$2 and return the last 12 rows where there is a match to get both the Home and Away Form for the particular team I'm interested in and create a new table in the Output worksheet for those last 12 games with the following headings
<tbody>
[TD="class: xl65, colspan: 2"]Date[/TD]
[TD="class: xl65, width: 122, colspan: 3"]Home Team[/TD]
[TD="class: xl65, width: 120, colspan: 3"]Away Team[/TD]
[TD="class: xl65, width: 120, colspan: 3"]Half Time Score[/TD]
[TD="class: xl65, width: 120, colspan: 3"]Full Time Score[/TD]
</tbody>
I know that the following formula would find and display what I am after...
{=IFERROR(INDEX('Historical Data'!B$2:B$9999,SMALL(IF((('Historical Data'!$C$2:$C$9999=Output!$B$2)+('Historical Data'!$D$2:$D$9999=Output!$B$2)),ROW('Historical Data'!B$2:B$9999)-ROW('Historical Data'!B$2)+1),ROWS('Historical Data'!B$2:'Historical Data'!B2))),"")}
However, it will find and match working from row 1 downwards and so extract the oldest data first as shown below (with West Brom being the search value in this instance)
<colgroup><col style="mso-width-source:userset;mso-width-alt:2340;width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:1755;width:36pt" width="48"> <col style="mso-width-source:userset;mso-width-alt:1536;width:32pt" width="42"> <col style="mso-width-source:userset;mso-width-alt:1462; width:30pt" span="11" width="40"> </colgroup><tbody>
[TD="class: xl65, width: 112, colspan: 2"]Date[/TD]
[TD="class: xl65, width: 122, colspan: 3"]Home Team[/TD]
[TD="class: xl65, width: 120, colspan: 3"]Away Team[/TD]
[TD="class: xl65, width: 120, colspan: 3"]Half Time[/TD]
[TD="class: xl65, width: 120, colspan: 3"]Full Time[/TD]
[TD="class: xl66, colspan: 2"]18/08/12[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65, colspan: 3"]Liverpool[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]3[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl66, colspan: 2"]25/08/12[/TD]
[TD="class: xl65, colspan: 3"]Tottenham[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl66, colspan: 2"]1/9/2012[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65, colspan: 3"]Everton[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl66, colspan: 2"]15/09/12[/TD]
[TD="class: xl65, colspan: 3"]Fulham[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]3[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl66, colspan: 2"]22/09/12[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65, colspan: 3"]Reading[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl66, colspan: 2"]30/09/12[/TD]
[TD="class: xl65, colspan: 3"]Aston Villa[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl66, colspan: 2"]6/10/2012[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65, colspan: 3"]QPR[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]3[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl66, colspan: 2"]20/10/12[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65, colspan: 3"]Man City[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]A[/TD]
[TD="class: xl66, colspan: 2"]28/10/12[/TD]
[TD="class: xl65, colspan: 3"]Newcastle[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl66, colspan: 2"]5/11/2012[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65, colspan: 3"]Southampton[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]0[/TD]
[TD="class: xl65"]H[/TD]
[TD="class: xl66, colspan: 2"]10/11/2012[/TD]
[TD="class: xl65, colspan: 3"]Wigan[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]A[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]A[/TD]
[TD="class: xl66, colspan: 2"]17/11/12[/TD]
[TD="class: xl65, colspan: 3"]West Brom[/TD]
[TD="class: xl65, colspan: 3"]Chelsea[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]D[/TD]
[TD="class: xl65"]2[/TD]
[TD="class: xl65"]1[/TD]
[TD="class: xl65"]H[/TD]
</tbody>
What I am needing to do is start from the most recent matches which are to be found at the bottom of the historic data table and work backwards.
Can it be done, and how could I do it?
Thanks