Find Value in Table

Steve 1962

Active Member
Joined
Jan 3, 2006
Messages
379
Office Version
  1. 365
Platform
  1. Windows
Hi

I am getting errors in column H. Although the data are shown on this one worksheet, in reality the table (cells A1 to C32) will be located on a separate worksheet.

The objective is to identify whether the team being analysed in cell E2 is playing "HOME" or "AWAY".

Thanks

Book1
ABCDEFGHI
1WeekTeam - HomeTeam - AwayTeam AnalysedWeekTeamGround
21Sea EaglesRabbitohsBroncos1Roosters#VALUE!Should read "HOME"
31RoostersBroncos2Rabbitohs#VALUE!Should read "AWAY"
41KnightsRaiders3Panthers#VALUE!Should read "HOME"
51WarriorsSharks4Cowboys#VALUE!Should read "AWAY"
61StormPanthers
71EelsBulldogs
81TitansDragons
91DolphinsCowboys
102BroncosRabbitohs
112SharksBulldogs
122PanthersEels
132RaidersTigers
142CowboysKnights
152StormWarriors
162Sea EaglesRoosters
172DolphinsDragons
183PanthersBroncos
193WarriorsRaiders
203RoostersRabbitohs
213BulldogsTitans
223DragonsCowboys
233TigersSharks
243EelsSea Eagles
253KnightsStorm
264RoostersPanthers
274RabbitohsBulldogs
284BroncosCowboys
294DragonsSea Eagles
304TitansDolphins
314WarriorsKnights
324SharksRaiders
Sheet3
Cell Formulas
RangeFormula
G2:G5G2=IFERROR(LOOKUP(2,1/($A$2:$A$32=$F2)/($C$2:$C$32=$E$2),$B$2:$B$32),LOOKUP(2,1/($A$2:$A$32=$F2)/($B$2:$B$32=$E$2),$C$2:$C$32))
H2:H5H2=CHOOSE(AGGREGATE(15,6,COLUMN($B$1:$C$1)/($B$2:$C$32=G2)/($A$2:$A$32=F2)-3,1),"Home","Away")
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hello, one of the options could be:

Excel Formula:
=SUBSTITUTE(MAP(F2:F5,G2:G5,LAMBDA(x,y,XLOOKUP(1,BYCOL(($A$2:$A$32=x)*($B$2:$C$32=y),LAMBDA(a,SUM(a))),$B$1:$C$1))),"Team - ","")
 
Upvote 0
Your column I looks the wrong way round to me. If you are analysing the Broncos, week 1 is at the Roosters ground so Bronco would be "Away" wouldn't they?

Anyway, going with what you have as the desired results
  • In col J I have adjusted your formula structure to produce those results. You had -3 where it should be -1. Perhaps the columns have changed and using COLUMN() in your AGGREGATE function like that is risky if the columns might change.
  • In col K is another alternative that (like @hagia_sofia's suggestion) produces all the results without having to copy down.
  • For you to consider I have also put a shorter alternative in col M to get the list of opponents

24 08 21.xlsm
ABCDEFGJKLM
1WeekTeam - HomeTeam - AwayTeam AnalysedWeekTeamGroundGroundTeam
21Sea EaglesRabbitohsBroncos1RoostersHomeHomeRoosters
31RoostersBroncos2RabbitohsAwayAwayRabbitohs
41KnightsRaiders3PanthersHomeHomePanthers
51WarriorsSharks4CowboysAwayAwayCowboys
61StormPanthers
71EelsBulldogs
81TitansDragons
91DolphinsCowboys
102BroncosRabbitohs
112SharksBulldogs
122PanthersEels
132RaidersTigers
142CowboysKnights
152StormWarriors
162Sea EaglesRoosters
172DolphinsDragons
183PanthersBroncos
193WarriorsRaiders
203RoostersRabbitohs
213BulldogsTitans
223DragonsCowboys
233TigersSharks
243EelsSea Eagles
253KnightsStorm
264RoostersPanthers
274RabbitohsBulldogs
284BroncosCowboys
294DragonsSea Eagles
304TitansDolphins
314WarriorsKnights
324SharksRaiders
Steve 1962
Cell Formulas
RangeFormula
G2:G5G2=IFERROR(LOOKUP(2,1/($A$2:$A$32=$F2)/($C$2:$C$32=$E$2),$B$2:$B$32),LOOKUP(2,1/($A$2:$A$32=$F2)/($B$2:$B$32=$E$2),$C$2:$C$32))
K2:K5K2=TOCOL(IF(B2:B32=E2,"Away",IF(C2:C32=E2,"Home",1/0)),2)
M2:M5M2=TOCOL(IF(B2:B32=E2,C2:C32,IF(C2:C32=E2,B2:B32,1/0)),2)
J2:J5J2=CHOOSE(AGGREGATE(15,6,COLUMN($B$1:$C$1)/($B$2:$C$32=G2)/($A$2:$A$32=F2)-1,1),"Home","Away")
Dynamic array formulas.
 
Upvote 0
Thanks Peter. Yes - you are correct, I had it wrong way round.

Does it matter that the source data (columns A, B & C) are on another worksheet (mentioned in my initial thread) ?
 
Upvote 0
I had it wrong way round.

Does it matter that the source data (columns A, B & C) are on another worksheet
Not at all, though I have modified the formulas a little.

Steve 1962.xlsm
ABC
1WeekTeam - HomeTeam - Away
21Sea EaglesRabbitohs
31RoostersBroncos
41KnightsRaiders
51WarriorsSharks
61StormPanthers
71EelsBulldogs
81TitansDragons
91DolphinsCowboys
102BroncosRabbitohs
112SharksBulldogs
122PanthersEels
132RaidersTigers
142CowboysKnights
152StormWarriors
162Sea EaglesRoosters
172DolphinsDragons
183PanthersBroncos
193WarriorsRaiders
203RoostersRabbitohs
213BulldogsTitans
223DragonsCowboys
233TigersSharks
243EelsSea Eagles
253KnightsStorm
264RoostersPanthers
274RabbitohsBulldogs
284BroncosCowboys
294DragonsSea Eagles
304TitansDolphins
314WarriorsKnights
324SharksRaiders
Sheet1


Steve 1962.xlsm
ABCD
1Team AnalysedWeekTeamGround
2Broncos1RoostersAway
32RabbitohsHome
43PanthersAway
54CowboysHome
Sheet2
Cell Formulas
RangeFormula
C2:C5C2=LET(b,Sheet1!B2:B32,c,Sheet1!C2:C32,TOCOL(IF(b=A2,c,IF(c=A2,b,1/0)),2))
D2:D5D2=TOCOL(IF(Sheet1!B2:B32=A2,"Home",IF(Sheet1!C2:C32=A2,"Away",1/0)),2)
Dynamic array formulas.
 
Upvote 0
Thanks Peter. I can get it to work on the same worksheet OK but when I refer to the source data on a separate worksheet, I get a #SPILL! error. Obviously I'm doing something wrong. The source data are contained in columns D, E & F on the separate worksheet.


Book1
DEF
1WeekTeam - HomeTeam - Away
21Sea EaglesRabbitohs
31RoostersBroncos
41KnightsRaiders
51WarriorsSharks
61StormPanthers
71EelsBulldogs
81TitansDragons
91DolphinsCowboys
102BroncosRabbitohs
112SharksBulldogs
122PanthersEels
132RaidersTigers
142CowboysKnights
152StormWarriors
162Sea EaglesRoosters
172DolphinsDragons
Sheet4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1,D1:I1Cell Value=""textYES
A1,D1:I1Cell Value=$B$1textNO
E2:F17Cell Value=""textYES
E2:F17Cell Value=$B$1textNO
Cells with Data Validation
CellAllowCriteria
E2:F17List=Teams
 
Upvote 0
I get a #SPILL! error.
The formula only needs to go in the top cell. Select all the cells below the top one in each column and 'Delete'

Steve 1962.xlsm
DEF
1WeekTeam - HomeTeam - Away
21Sea EaglesRabbitohs
31RoostersBroncos
41KnightsRaiders
51WarriorsSharks
61StormPanthers
71EelsBulldogs
81TitansDragons
91DolphinsCowboys
102BroncosRabbitohs
112SharksBulldogs
122PanthersEels
132RaidersTigers
142CowboysKnights
152StormWarriors
162Sea EaglesRoosters
172DolphinsDragons
183PanthersBroncos
193WarriorsRaiders
203RoostersRabbitohs
213BulldogsTitans
223DragonsCowboys
233TigersSharks
243EelsSea Eagles
253KnightsStorm
264RoostersPanthers
274RabbitohsBulldogs
284BroncosCowboys
294DragonsSea Eagles
304TitansDolphins
314WarriorsKnights
324SharksRaiders
Sheet1


Steve 1962.xlsm
ABCD
1Team AnalysedWeekTeamGround
2Broncos1RoostersAway
32RabbitohsHome
43PanthersAway
54CowboysHome
6
Sheet2
Cell Formulas
RangeFormula
C2:C5C2=LET(b,Sheet1!E2:E32,c,Sheet1!F2:F32,TOCOL(IF(b=A2,c,IF(c=A2,b,1/0)),2))
D2:D5D2=TOCOL(IF(Sheet1!E2:E32=A2,"Home",IF(Sheet1!F2:F32=A2,"Away",1/0)),2)
Dynamic array formulas.
 
Upvote 0
Thanks Peter. I now do not receive the SPILL error so that is fixed. Only thing now is that the range of formulas in column E, only extends down as far as row 25. It does not complete down all the way to row 28. I have pressed CONTROL + arrow down to the last row 1048576 in column E and there are no entries below row 25. Not sure why it doesn't complete to row 28.



Book1
ABCDEF
1BroncosWeekTeamGround
21RoostersAway
32RabbitohsHome
43PanthersAway
54CowboysHome
65StormAway
76DolphinsHome
87RaidersHome
98TigersAway
109RoostersHome
1110EelsAway
1211Sea EaglesAway
1312TitansHome
1413#N/AHome
1514SharksAway
1615RabbitohsAway
1716#N/AHome
1817WarriorsHome
1918PanthersAway
2019DragonsHome
2120KnightsAway
2221BulldogsAway
2322TitansHome
2423CowboysAway
2524#N/AHomeRange end at this row
2625Eels
2726Dolphins
2827Storm
Broncos
Cell Formulas
RangeFormula
A1A1=TEXTAFTER(CELL("filename",A1),"]")
E2E2=TOCOL(IF(Table!E2:E217=A1,"Home",IF(Table!F2:F217=A1,"Away",1/0)),2)
D2:D28D2=IFERROR(LOOKUP(2,1/(Main[Week]=$C2)/(Main[Team - Away]=$A$1),Main[Team - Home]),LOOKUP(2,1/(Main[Week]=$C2)/(Main[Team - Home]=$A$1),Main[Team - Away]))
 
Upvote 0
Can you show us the 'Table' sheet with XL2BB as well?

Is 'Table' the sheet with the 'Main' table on it?
 
Upvote 0
OK Peter. Here is the "Table' sheet, containing the 'Main' table. I have only provided up to row 25, as the entire table is quite long (covers 27 x weeks over a couple of hundred rows).

Thanks

Book1
ABCDEFGHIJKLMNOPQRST
1SequenceWeekTeam - HomeTeam - AwayScore - HomeScore - AwayTries - HomeTries - AwayGoals - HomeGoals - AwayP / DColumn1Result - HomeResult - AwayDrawWinnerWinSelection
211Sea EaglesRabbitohs3624656.02.012HomeW  Sea Eagles1Sea Eagles
321RoostersBroncos2010324.01.010HomeW  Roosters1Roosters
431KnightsRaiders1228252.04.0-16Away W Raiders1Raiders
541WarriorsSharks1216232.02.0-4Away W Sharks0Warriors
651StormPanthers80102.00.08HomeW  Storm1Storm
761EelsBulldogs268425.00.018HomeW  Eels1Eels
871TitansDragons428150.04.0-24Away W Dragons0Titans
981DolphinsCowboys1843373.07.5-25Away W Cowboys0Dolphins
1092BroncosRabbitohs2818534.03.010HomeW  Broncos1Broncos
11102SharksBulldogs256414.51.019HomeW  Sharks1Sharks
12112PanthersEels2618533.03.08HomeW  Panthers0Eels
13122RaidersTigers3212526.02.020HomeW  Raiders1Raiders
14132CowboysKnights2120432.54.01HomeW  Cowboys1Cowboys
15142StormWarriors3026545.05.04HomeW  Storm1Storm
16152Sea EaglesRoosters2114334.51.07HomeW  Sea Eagles1Sea Eagles
17162DolphinsDragons380705.038HomeW  Dolphins0Dragons
18173PanthersBroncos3412625.02.022HomeW  Panthers1Panthers
19183WarriorsRaiders1810323.01.08HomeW  Warriors0Raiders
20193RoostersRabbitohs486818.01.042HomeW  Roosters1Roosters
21203BulldogsTitans320604.032HomeW  Bulldogs0Titans
22213DragonsCowboys2446484.07.0-22Away W Cowboys1Cowboys
23223TigersSharks326516.01.026HomeW  Tigers0Sharks
24233EelsSea Eagles2824544.04.04HomeW  Eels0Sea Eagles
25243KnightsStorm1412223.02.02HomeW  Knights0Storm
Sheet5
Cell Formulas
RangeFormula
M2:M25M2=IF(AND(Main[@[Score - Home]]="",Main[@[Score - Away]]=""),"",G2-H2)
N2:N25N2=IF(AND(Main[@[Score - Home]]="",Main[@[Score - Away]]=""),"",IF(Main[@[Score - Home]]>Main[@[Score - Away]],"Home",IF(Main[@[Score - Home]]<Main[@[Score - Away]],"Away","Draw")))
O2:O25O2=IF(Main[@[Score - Home]]>Main[@[Score - Away]],"W","")
P2:P25P2=IF(Main[@[Score - Home]]<Main[@[Score - Away]],"W","")
Q2:Q25Q2=IF(Main[@[Score - Home]]+Main[@[Score - Away]]=0,"",IF(Main[@[Score - Home]]=Main[@[Score - Away]],"D",""))
R2:R25R2=IF(Main[@[Score - Home]]>Main[@[Score - Away]],Main[@[Team - Home]],IF(Main[@[Score - Home]]=Main[@[Score - Away]],"",Main[@[Team - Away]]))
S2:S25S2=IF(AND(Main[@[Score - Home]]=0,Main[@[Score - Away]]=0),"",IF(Main[@Winner]=Main[@Selection],1,0))
Cells with Data Validation
CellAllowCriteria
E2:F25List=Teams
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,189
Members
452,616
Latest member
intern444

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