AND and OR with INDEX MATCH problem

markly

New Member
Joined
Aug 14, 2007
Messages
13
Office Version
  1. 2010
Platform
  1. Windows
I have a spreadsheet for the World Cup, with the each game's teams in Col. F and Col. J and their scores in Cols K-N. In Col. P all teams are listed in alphabetical order. Alongside that column I want to show just the opposing team if the game has not yet played, or if it has played "W v", "Dr v" or "L v" and the opposing team.

My formula works perfectly if the alphabetical team is in Col. F, but I get #NA if the alphabetical team is in Col. J. I cannot figure out why the formula works for teams in Col. F but not for teams in Col. J. The mini sheet is:

DateNZTGpTeam 1DrawTeam 2T1 FTT1 HTT2 HTT2 FT
444
Mon 21 NovAQatar6.005.002.00Ecuador0022Group StageGame 1
Tue 22 Nov2amBEngland1.304.5011.00Iran6302ArgentinaL v Saudi Arabia
Tue 22 Nov5amASenegal6.003.601.62Netherlands0002Australia#N/A
Tue 22 Nov8amBUSA2.373.003.30Wales1101BelgiumW v Canada
Tue 22 Nov11pmCArgentina1.128.0019.00Saudi Arabia1102BrazilSerbia
Wed 23 Nov2amDDenmark1.533.756.50Tunisia0000Cameroon#N/A
Wed 23 Nov5amCMexico2.502.883.00Poland0000Canada#N/A
Wed 23 Nov8amDFrance1.226.0013.00Australia4211Costa Rica#N/A
Wed 23 Nov11pmFMorocco3.753.102.00Croatia0000Croatia#N/A
Thu 24 Nov2amEGermany1.404.507.00Japan1102DenmarkDr v Tunisia
Thu 24 Nov5amESpain1.128.0020.00Costa Rica7300Ecuador#N/A
Thu 24 Nov8amFBelgium1.204.206.50Canada1100EnglandW v Iran
Thu 24 Nov11pmGSwitzerland1.723.405.00CameroonFranceW v Australia
Fri 25 Nov2amHUruguay1.673.505.50South KoreaGermanyL v Japan
Fri 25 Nov5amHPortugal1.364.509.00GhanaGhana#N/A
Fri 25 Nov8amGBrazil1.454.337.00SerbiaIran#N/A
Fri 25 Nov11pmBWales2.003.004.00IranJapan#N/A
Sat 26 Nov2amAQatar6.003.601.62SenegalMexicoDr v Poland
Sat 26 Nov5amANetherlands1.723.504.50EcuadorMoroccoDr v Croatia
Sat 26 Nov8amBEngland1.534.005.50USANetherlands#N/A
Sat 26 Nov11pmDTunisia2.103.103.60AustraliaPoland#N/A
Sun 27 Nov2amCPoland1.833.404.50Saudi ArabiaPortugalGhana
Sun 27 Nov5amDFrance1.803.504.50DenmarkQatarL v Ecuador
Sun 27 Nov8amCArgentina1.504.007.00MexicoSaudi Arabia#N/A
Sun 27 Nov11pmEJapan1.454.207.50Costa RicaSenegalL v Netherlands
Mon 28 Nov2amFBelgium1.833.404.50MoroccoSerbia#N/A
Mon 28 Nov5amFCroatia2.253.253.30CanadaSouth Korea#N/A
Mon 28 Nov8amESpain2.303.502.88GermanySpainW v Costa Rica
Mon 28 Nov11pmGCameroon5.003.601.72SerbiaSwitzerlandCameroon
Tue 29 Nov2amHSouth Korea2.603.002.88GhanaTunisia#N/A
Tue 29 Nov5amGBrazil1.404.337.50SwitzerlandUruguaySouth Korea
Tue 29 Nov8amHPortugal1.913.254.20UruguayUSADr v Wales
Wed 30 Nov4amAEcuadorSenegalWales#N/A
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

I cannot figure out why the formula works for teams in Col. F but not for teams in Col. J.
:oops: Unfortunately, you did not give us the formula so no chance to analyse it for you.

The mini sheet is:
It would be better if you did use 'Mini Sheet' rather than 'Table Only'
 
Upvote 0
XL2BB did not work as it was supposed to. After selecting my range, I clicked Mini Sheet but got an error message "1004 - Application-defined or object-defined error". I then clicked Table Only and got a message "Mini Sheet was successfully copied to clipboard", so I pasted it in the post.

This is the formula in Q5:
{=IF(AND(OR($F$3:$F$18=P5),ISNUMBER(INDEX($K$3:$K$18,MATCH(P5,$F$3:$F$18,0))),INDEX($K$3:$K$18,MATCH(P5,$F$3:$F$18,0))>INDEX($N$3:$N$18,MATCH(P5,$F$3:$F$18,0))),"W v "&INDEX($J$3:$J$18,MATCH(P5,$F$3:$F$18,0)),
IF(AND(OR($F$3:$F$18=P5),ISNUMBER(INDEX($K$3:$K$18,MATCH(P5,$F$3:$F$18,0))),INDEX($K$3:$K$18,MATCH(P5,$F$3:$F$18,0))=INDEX($N$3:$N$18,MATCH(P5,$F$3:$F$18,0))),"Dr v "&INDEX($J$3:$J$18,MATCH(P5,$F$3:$F$18,0)),
IF(AND(OR($F$3:$F$18=P5),ISNUMBER(INDEX($K$3:$K$18,MATCH(P5,$F$3:$F$18,0))),INDEX($K$3:$K$18,MATCH(P5,$F$3:$F$18,0))<INDEX($N$3:$N$18,MATCH(P5,$F$3:$F$18,0))),"L v "&INDEX($J$3:$J$18,MATCH(P5,$F$3:$F$18,0)),
IF(OR($F$3:$F$18=P5),INDEX($J$3:$J$18,MATCH(P5,$F$3:$F$18,0)),
IF(AND(OR($J$3:$J$18=P5),ISNUMBER(INDEX($N$3:$N$18,MATCH(P5,$J$3:$J$18,0))),INDEX($K$3:$K$18,MATCH(P5,$J$3:$J$18,0))>INDEX($N$3:$N$18,MATCH(P5,$J$3:$J$18,0))),"L v "&INDEX($F$3:$F$18,MATCH(P5,$J$3:$J$18,0)),
IF(AND(OR($J$3:$J$18=P5),ISNUMBER(INDEX($N$3:$N$18,MATCH(P5,$J$3:$J$18,0))),INDEX($K$3:$K$18,MATCH(P5,$J$3:$J$18,0))=INDEX($N$3:$N$18,MATCH(P5,$J$3:$J$18,0))),"Dr v "&INDEX($F$3:$F$18,MATCH(P5,$J$3:$J$18,0)),
IF(AND(OR($J$3:$J$18=P5),ISNUMBER(INDEX($N$3:$N$18,MATCH(P5,$J$3:$J$18,0))),INDEX($K$3:$K$18,MATCH(P5,$J$3:$J$18,0))<INDEX($N$3:$N$18,MATCH(P5,$J$3:$J$18,0))),"W v "&INDEX($F$3:$F$18,MATCH(P5,$J$3:$J$18,0)),
IF(OR($J$3:$J$18=P5),INDEX($F$3:$F$18,MATCH(P5,$J$3:$J$18,0))))))))))}
 
Upvote 0
Thanks for the formula.
  1. What about the first paragraph in my previous post?

  2. Is there some reason why your formula only refers to rows 3:18 when clearly your data is bigger than that?
 
Last edited:
Upvote 0
Thanks Peter. Have now updated my account details. For some unknown reason, XL2BB just won't let me send you a proper Mini Sheet. Is it because my Excel version is 2010?
 
Upvote 0
Have now updated my account details.
Thanks. (y)

For some unknown reason, XL2BB just won't let me send you a proper Mini Sheet.
I will try to find out more about that.

Is it because my Excel version is 2010?
It shouldn't be as your version is listed as one of the relevant applicable versions

1670143713527.png


Now, what about my second question in my last post?

(It would make things much easier if I did not have to keep asking things twice ;))
 
Upvote 0
For some unknown reason, XL2BB just won't let me send you a proper Mini Sheet. Is it because my Excel version is 2010?
@markly: It could be something related to the named range(s) in the workbook. Could you please retry by unchecking the Named Ranges option in the Additional Info section?

1670164785204.png


If it works when you unchecked the option then it means XL2BB can't work with the named range(s) in your workbook. I need to see the workbook to be able to give more information in this case.

If it doesn't work (or there is no named range in the workbook), then I can try to find out if it is related to Excel version or actually what it is, but I'll still need the workbook. Perhaps you could upload it somewhere that I can download and test?
 
Upvote 0
Sorry about Q2. Col. Q relates to just the first round of the three Group games, which are rows 3:18. There will be a Col. R for rows 19:34 and a Col. S for rows 35:50, the 2nd and third games. There are no named ranges in the sheet, so after the first unsuccessful attempt to create a Mini Sheet I unchecked the Named Ranges box to see if that would help. It didn't.

I tested each IF condition with F9 and got 7 FALSE and one TRUE, as expected, yet the #NA result. At one stage when trying to get the formula to work for a Col. J team, I deleted the first block of the formula (the IF(OR(F3:F18) lines), leaving just the lines starting with IF(OR(J3:J18), and got the correct result. I wonder if the whole formula has too many INDEX/MATCHs for Excel?

How can I send you the spreadsheet independently of XL2BB? The button below only allows an image to be sent.
 
Upvote 0
How can I send you the spreadsheet independently of XL2BB?
I don't need the actual workbook but @smozgur does - see his two posts above.

Using your original formula structure you could use this massive adaptation o_O ...

Excel Formula:
{=IF(ISERROR(IF(AND(OR($F$3:$F$18=P4),ISNUMBER(INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))>INDEX($N$3:$N$18,MATCH(P4,$F$3:$F$18,0))),"W v "&INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(AND(OR($F$3:$F$18=P4),ISNUMBER(INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))=INDEX($N$3:$N$18,MATCH(P4,$F$3:$F$18,0))),"Dr v "&INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(AND(OR($F$3:$F$18=P4),ISNUMBER(INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))<INDEX($N$3:$N$18,MATCH(P4,$F$3:$F$18,0))),"L v "&INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(OR($F$3:$F$18=P4),INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(AND(OR($J$3:$J$18=P4),ISNUMBER(INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),INDEX($K$3:$K$18,MATCH(P4,$J$3:$J$18,0))>INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),"L v "&INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)),
IF(AND(OR($J$3:$J$18=P4),ISNUMBER(INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),INDEX($K$3:$K$18,MATCH(P4,$J$3:$J$18,0))=INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),"Dr v "&INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)),
IF(AND(OR($J$3:$J$18=P4),ISNUMBER(INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),INDEX($K$3:$K$18,MATCH(P4,$J$3:$J$18,0))<INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),"W v "&INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)),
IF(OR($J$3:$J$18=P4),INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0))))))))))),IF(AND(OR($J$3:$J$18=P4),ISNUMBER(INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))>INDEX($K$3:$K$18,MATCH(P4,$J$3:$J$18,0))),"W v "&INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)),
IF(AND(OR($J$3:$J$18=P4),ISNUMBER(INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))=INDEX($K$3:$K$18,MATCH(P4,$J$3:$J$18,0))),"Dr v "&INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)),
IF(AND(OR($J$3:$J$18=P4),ISNUMBER(INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))<INDEX($K$3:$K$18,MATCH(P4,$J$3:$J$18,0))),"L v "&INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)),
IF(OR($J$3:$J$18=P4),INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)),
IF(AND(OR($F$3:$F$18=P4),ISNUMBER(INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),INDEX($N$3:$N$18,MATCH(P4,$F$3:$F$18,0))>INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),"L v "&INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(AND(OR($F$3:$F$18=P4),ISNUMBER(INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),INDEX($N$3:$N$18,MATCH(P4,$F$3:$F$18,0))=INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),"Dr v "&INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(AND(OR($F$3:$F$18=P4),ISNUMBER(INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),INDEX($N$3:$N$18,MATCH(P4,$F$3:$F$18,0))<INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),"W v "&INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(OR($F$3:$F$18=P4),INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)))))))))),IF(AND(OR($F$3:$F$18=P4),ISNUMBER(INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))>INDEX($N$3:$N$18,MATCH(P4,$F$3:$F$18,0))),"W v "&INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(AND(OR($F$3:$F$18=P4),ISNUMBER(INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))=INDEX($N$3:$N$18,MATCH(P4,$F$3:$F$18,0))),"Dr v "&INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(AND(OR($F$3:$F$18=P4),ISNUMBER(INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))),INDEX($K$3:$K$18,MATCH(P4,$F$3:$F$18,0))<INDEX($N$3:$N$18,MATCH(P4,$F$3:$F$18,0))),"L v "&INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(OR($F$3:$F$18=P4),INDEX($J$3:$J$18,MATCH(P4,$F$3:$F$18,0)),
IF(AND(OR($J$3:$J$18=P4),ISNUMBER(INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),INDEX($K$3:$K$18,MATCH(P4,$J$3:$J$18,0))>INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),"L v "&INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)),
IF(AND(OR($J$3:$J$18=P4),ISNUMBER(INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),INDEX($K$3:$K$18,MATCH(P4,$J$3:$J$18,0))=INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),"Dr v "&INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)),
IF(AND(OR($J$3:$J$18=P4),ISNUMBER(INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),INDEX($K$3:$K$18,MATCH(P4,$J$3:$J$18,0))<INDEX($N$3:$N$18,MATCH(P4,$J$3:$J$18,0))),"W v "&INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)),
IF(OR($J$3:$J$18=P4),INDEX($F$3:$F$18,MATCH(P4,$J$3:$J$18,0)))))))))))}


... but I think the considerably shorter one below does the same job (& I don't think that it will need Ctrl+Shift+Enter confirmation in your Excel version)

markly.xlsm
FJKNOPQ
1Team 1T1 FTT2 FT
2
3QatarEcuador02Group StageGame 1
4EnglandIran62ArgentinaL v Saudi Arabia
5SenegalNetherlands02AustraliaL v France
6USAWales11BelgiumW v Canada
7ArgentinaSaudi Arabia12BrazilSerbia
8DenmarkTunisia00CameroonSwitzerland
9MexicoPoland00CanadaL v Belgium
10FranceAustralia41Costa RicaL v Spain
11MoroccoCroatia00CroatiaDr v Morocco
12GermanyJapan12DenmarkDr v Tunisia
13SpainCosta Rica70EcuadorW v Qatar
14BelgiumCanada10EnglandW v Iran
15SwitzerlandCameroonFranceW v Australia
16UruguaySouth KoreaGermanyL v Japan
17PortugalGhanaGhanaPortugal
18BrazilSerbiaIranL v England
19WalesIranJapanW v Germany
20QatarSenegalMexicoDr v Poland
21NetherlandsEcuadorMoroccoDr v Croatia
22EnglandUSANetherlandsW v Senegal
23TunisiaAustraliaPolandDr v Mexico
24PolandSaudi ArabiaPortugalGhana
25FranceDenmarkQatarL v Ecuador
26ArgentinaMexicoSaudi ArabiaW v Argentina
27JapanCosta RicaSenegalL v Netherlands
28BelgiumMoroccoSerbiaBrazil
29CroatiaCanadaSouth KoreaUruguay
30SpainGermanySpainW v Costa Rica
31CameroonSerbiaSwitzerlandCameroon
32South KoreaGhanaTunisiaDr v Denmark
33BrazilSwitzerlandUruguaySouth Korea
34PortugalUruguayUSADr v Wales
35EcuadorSenegalWalesDr v USA
Sheet1
Cell Formulas
RangeFormula
Q4:Q35Q4=IF(ISERROR(IF(VLOOKUP(P4,F$3:K$18,6,0)="","",CHOOSE(SIGN(INDEX(K$3:K$18,MATCH(P4,F$3:F$18,0))-INDEX(N$3:N$18,MATCH(P4,F$3:F$18,0)))+2,"L v ","Dr v ","W v "))),IF(VLOOKUP(P4,J$3:N$18,5,0)="","",CHOOSE(SIGN(INDEX(N$3:N$18,MATCH(P4,J$3:J$18,0))-INDEX(K$3:K$18,MATCH(P4,J$3:J$18,0)))+2,"L v ","Dr v ","W v ")),IF(VLOOKUP(P4,F$3:K$18,6,0)="","",CHOOSE(SIGN(INDEX(K$3:K$18,MATCH(P4,F$3:F$18,0))-INDEX(N$3:N$18,MATCH(P4,F$3:F$18,0)))+2,"L v ","Dr v ","W v ")))&IF(COUNTIF(F$3:F$18,P4),INDEX(J$3:J$18,MATCH(P4,F$3:F$18,0)),INDEX(F$3:F$18,MATCH(P4,J$3:J$18,0)))
 
Upvote 0
Solution

Forum statistics

Threads
1,215,086
Messages
6,123,031
Members
449,092
Latest member
ikke

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