Find the nth occurrence of a word, to find the column_num, to find the student name.

Dave_O

New Member
Joined
Dec 3, 2019
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I am running a spreadsheet that carries over the student name to the next round when they "Pass" - when a result is correct.

I've been trying to use index/small/match to find the nth occurrence of the word "Pass", to find the column_num, to find the student name.

cell E12 returns an #NUM! error with {=INDEX($C$1:$V$1,,SMALL(MATCH("Pass",$C$8:$V$8,0),2))}


Row 12 student name, these students pass round one:
C12 = Barbara (first occurrence of Pass)
E12 = David (second occurrence of Pass)
G12 = James (third occurrence of Pass)
I12 = Jennifer (fourth occurrence of Pass)
K12 = John (fifth occurrence of Pass)


Row 21 student name, these students pass round two:
C21 = David (first occurrence of Pass)
E21 = Jennifer (second occurrence of Pass)
G21 = John (third occurrence of Pass)




Students who pass move to next round.xlsb
ABCDEFGHIJKLMNOPQRST
1Student NameBarbaraResultCharlesResultDavidResultElizabethResultJamesResultJenniferResultJessicaResultJohnResult
2Round 1Answer 111Correct37Incorrect78Incorrect15Incorrect88Incorrect4Incorrect28Incorrect1Incorrect
3Round 1Answer 213Incorrect43Incorrect75Correct80Incorrect37Incorrect35Incorrect41Incorrect78Incorrect
4Round 1Answer 330Incorrect62Incorrect65Incorrect75Incorrect79Correct73Incorrect74Incorrect83Incorrect
5Round 1Answer 465Incorrect71Incorrect51Incorrect29Incorrect26Incorrect2Correct49Incorrect81Incorrect
6Round 1Answer 546Incorrect22Incorrect48Incorrect11Incorrect44Incorrect31Incorrect77Incorrect74Correct
7Round 1Answer 624Incorrect63Incorrect67Incorrect21Incorrect57Incorrect33Incorrect72Incorrect54Incorrect
8Final ResultPassFailPassFailPassPassFailPass
9
10
11Find 1st PassBarbaraFind 2nd PassDavidFind 3rd PassJamesFind 4th PassJenniferFind 5th PassJohn
12Student NameBarbaraResult#NUM!Result#NUM!Result#NUM!Result#NUM!Result
13Round 2Answer 172Incorrect6Correct49Incorrect66Incorrect26Incorrect
14Round 2Answer 283Incorrect98Incorrect59Incorrect42Correct47Incorrect
15Round 2Answer 397Incorrect22Incorrect39Incorrect20Incorrect93Correct
16Round 2Answer 449Incorrect13Incorrect32Correct76Incorrect48Incorrect
17Final ResultFailPassPassPassPass
18
19
20Find 1st PassDavidFind 2nd PassJamesFind 3rd PassJenniferFind 4th PassJohn
21Student Name#NUM!ResultResultResultResult
22Round 3Answer 144Correct72Inccorect46Inccorect28Inccorect
23Round 3Answer 231Inccorect76Inccorect79Correct74Inccorect
24Round 3Answer 376Correct26Inccorect100Inccorect67Inccorect
25Round 3Answer 467Inccorect74Inccorect98Correct99Inccorect
26Final ResultPassFailPassFail
27
28
29
30
Sheet1
Cell Formulas
RangeFormula
C8,Q8,O8,M8,K8,I8,G8,E8C8=IF(COUNTIF(D2:D7,"Correct")>0,"Pass","Fail")
C12C12=INDEX($C$1:$R$1,,SMALL(MATCH("Pass",$C$8:$R$8,0),1))
E12E12=INDEX($C$1:$R$1,,SMALL(MATCH("Pass",$C$8:$R$8,0),2))
G12G12=INDEX($C$1:$R$1,,SMALL(MATCH("Pass",$C$8:$R$8,0),3))
I12I12=INDEX($C$1:$R$1,,SMALL(MATCH("Pass",$C$8:$R$8,0),4))
K12K12=INDEX($C$1:$R$1,,SMALL(MATCH("Pass",$C$8:$R$8,0),5))
C17,I26,G26,E26,C26,K17,I17,G17,E17C17=IF(COUNTIF(D13:D16,"Correct")>0,"Pass","Fail")
C21C21=INDEX($C$12:$L$12,,SMALL(MATCH("Pass",$C$17:$L$17,0),1))
Press CTRL+SHIFT+ENTER to enter array formulas.
 

Attachments

  • Screenshot.png
    Screenshot.png
    50.8 KB · Views: 9

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try
C12
=INDEX($C$1:$R$1,AGGREGATE(15,6,(COLUMN($C$1:$R$1)-COLUMN($C$1)+1)/($C$8:$R$8="Pass"),1))
E12
=INDEX($C$1:$R$1,AGGREGATE(15,6,(COLUMN($C$1:$R$1)-COLUMN($C$1)+1)/($C$8:$R$8="Pass"),2))
G12
=INDEX($C$1:$R$1,AGGREGATE(15,6,(COLUMN($C$1:$R$1)-COLUMN($C$1)+1)/($C$8:$R$8="Pass"),3))
and so on

C21
=INDEX($C$12:$L$12,AGGREGATE(15,6,(COLUMN($C$12:$L$12)-COLUMN($C$12)+1)/($C$17:$L$17="Pass"),1))
E21
=INDEX($C$12:$L$12,AGGREGATE(15,6,(COLUMN($C$12:$L$12)-COLUMN($C$12)+1)/($C$17:$L$17="Pass"),2))
and so on

M.
 
Upvote 0
Solution
Thank you so much, Marcelo.
I have not come across AGGREGATE before and I will study up tonight on its functionality, for future uses.

Thanks for showing me something new!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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