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
 
Thanks so much, Peter. The short formula does the job perfectly, so I did not try your long adaptation of mine. You are right about not needing to use Ctrl+Shift+Enter with the short formula. Your ability with Excel is truly amazing (at least to me) to come up with such an elegant formula involving IF, ISERROR, VLOOKUP, CHOOSE, SIGN, INDEX, MATCH and COUNTIF. [I will now try to reply to smozgur re XL2BB.]
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
@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?

View attachment 80153

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?
Hi smozgur
You have kindly offered to try to solve the XL2BB problem that prevented me creating a Mini Sheet. For that you need my workbook. How can I send it to you when I can upload only images via the forum? Do you have an email address that I can send the workbook to, or is there some other way?
 
Upvote 0
Do you have an email address that I can send the workbook to, or is there some other way?
Check your Conversations at the top right of the forum.

1670225147152.png
 
Upvote 0
Thanks for the sample workbook, @markly.

I tested it on Excel 2010/Windows 7, and I can get the mini-sheet without problems. I selected the whole range (except below row 52 because it exceeds the limit that could be posted on the forum with XL2BB), and it generated the mini-sheet code as shown below.

Does XL2BB still fail if you open a brand new workbook, enter something simple into a small range and create a mini-sheet by selecting that range? I believe it should because I don't think this is related to the workbook. It could be something related to your Excel installation, or even Windows, I really can't tell what it is. I'm afraid I am stuck at this point since I can't reproduce the same behavior by using the exact same workbook.

2022 World Cup 0.xlsx
ABCDEFGHIJKLMNOPQ
1StageDateNZTGpTeam 1DrawTeam 2T1 FTT1 HTT2 HTT2 FT
2444
3Group1st GamesMon 21 NovAQatar6.005.002.00Ecuador0022Group StageGame 1
4Tue 22 Nov2amBEngland1.304.5011.00Iran6302ArgentinaL v Saudi Arabia
5Tue 22 Nov5amASenegal6.003.601.62Netherlands0002Australia#N/A
6Tue 22 Nov8amBUSA2.373.003.30Wales1101BelgiumW v Canada
7Tue 22 Nov11pmCArgentina1.128.0019.00Saudi Arabia1102BrazilSerbia
8Wed 23 Nov2amDDenmark1.533.756.50Tunisia0000Cameroon#N/A
9Wed 23 Nov5amCMexico2.502.883.00Poland0000Canada#N/A
10Wed 23 Nov8amDFrance1.226.0013.00Australia4211Costa Rica#N/A
11Wed 23 Nov11pmFMorocco3.753.102.00Croatia0000Croatia#N/A
12Thu 24 Nov2amEGermany1.404.507.00Japan1102DenmarkDr v Tunisia
13Thu 24 Nov5amESpain1.128.0020.00Costa Rica7300Ecuador#N/A
14Thu 24 Nov8amFBelgium1.204.206.50Canada1100EnglandW v Iran
15Thu 24 Nov11pmGSwitzerland1.723.405.00CameroonFranceW v Australia
16Fri 25 Nov2amHUruguay1.673.505.50South KoreaGermanyL v Japan
17Fri 25 Nov5amHPortugal1.364.509.00GhanaGhana#N/A
18Fri 25 Nov8amGBrazil1.454.337.00SerbiaIran#N/A
192nd GamesFri 25 Nov11pmBWales2.003.004.00IranJapan#N/A
20Sat 26 Nov2amAQatar6.003.601.62SenegalMexicoDr v Poland
21Sat 26 Nov5amANetherlands1.723.504.50EcuadorMoroccoDr v Croatia
22Sat 26 Nov8amBEngland1.534.005.50USANetherlands#N/A
23Sat 26 Nov11pmDTunisia2.103.103.60AustraliaPoland#N/A
24Sun 27 Nov2amCPoland1.833.404.50Saudi ArabiaPortugalGhana
25Sun 27 Nov5amDFrance1.803.504.50DenmarkQatarL v Ecuador
26Sun 27 Nov8amCArgentina1.504.007.00MexicoSaudi Arabia#N/A
27Sun 27 Nov11pmEJapan1.454.207.50Costa RicaSenegalL v Netherlands
28Mon 28 Nov2amFBelgium1.833.404.50MoroccoSerbia#N/A
29Mon 28 Nov5amFCroatia2.253.253.30CanadaSouth Korea#N/A
30Mon 28 Nov8amESpain2.303.502.88GermanySpainW v Costa Rica
31Mon 28 Nov11pmGCameroon5.003.601.72SerbiaSwitzerlandCameroon
32Tue 29 Nov2amHSouth Korea2.603.002.88GhanaTunisia#N/A
33Tue 29 Nov5amGBrazil1.404.337.50SwitzerlandUruguaySouth Korea
34Tue 29 Nov8amHPortugal1.913.254.20UruguayUSADr v Wales
353rd GamesWed 30 Nov4amAEcuadorSenegalWales#N/A
36Wed 30 Nov4amANetherlandsQatar
37Wed 30 Nov8amBIranUSA
38Wed 30 Nov8amBWalesEngland
39Thu 1 Dec4amDTunisiaFrance
40Thu 1 Dec4amDAustraliaDenmark
41Thu 1 Dec8amCPolandArgentina
42Thu 1 Dec8amCSaudi ArabiaMexico
43Fri 2 Dec4amFCroatiaBelgium
44Fri 2 Dec4amFCanadaMorocco
45Fri 2 Dec8amEJapanSpain
46Fri 2 Dec8amECosta RicaGermany
47Sat 3 Dec4amHSouth KoreaPortugal
48Sat 3 Dec4amHGhanaUruguay
49Sat 3 Dec8amGSerbiaSwitzerland
50Sat 3 Dec8amGCameroonBrazil
Games
Cell Formulas
RangeFormula
G2G2=SUM(IF(K3:K50>N3:N50,1))
H2H2=SUM(IF((ISNUMBER(N3:N50))*(K3:K50=N3:N50),1))
I2I2=SUM(IF(K3:K50<N3:N50,1))
Q4:Q35Q4=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))))))))))
C4,C47,C43,C39,C35,C32,C28,C24,C20,C16,C12,C8C4=C3+1
C48:C50,C44:C46,C40:C42,C36:C38,C33:C34,C29:C31,C25:C27,C21:C23,C17:C19,C13:C15,C9:C11,C5:C7C5=C4
Press CTRL+SHIFT+ENTER to enter array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I3:I50Expression=K3<N3textNO
H3:H50Expression=AND(ISNUMBER(N3),K3=N3)textNO
G3:G50Expression=K3>N3textNO
 
Upvote 0
I have just created this Mini Sheet okay:
Book1
ABC
1ABC
2GreenBlueRed
3PinkYellowOrange
4
5
6
Sheet1

so immediately tried again with C1:Q35 of the World Cup workbook but again got the error message (see image).
No point in spending any more time on the problem, so thanks very much for looking into it.
Kind regards
Mark
 

Attachments

  • image_2022-12-06_095940662.png
    image_2022-12-06_095940662.png
    105.8 KB · Views: 4
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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