Index/Match return column header (multiple occurrences)

bbr25

New Member
Joined
Aug 16, 2018
Messages
3
Hi

I am trying to lookup a value in Column A then look across that row to find a string and return the Column header. There may be multiple occurrences of the string in that row and I need to return all column headers where there is a match. The data I am looking up is on a closed workbook.

I am able to get the column header of the first match using the following formula:

=INDEX('C:\Users\***\[workbookname.xlsm]Log'!$M$5:$FP$5,MATCH("NO",INDEX('C:\Users\***\[workbookname.xlsm]Log'!$M$6:$FP$2000,MATCH(A2,'C:\Users\***\[workbookname.xlsm]Log'!$A$6:$A$2000,0),),0))

But I am unsure how to fill that formula right to get any further matches in that row.

E.g.

Closed lookup workbook:

Column A .. Column M Column N Column O Column P Column Q .. Column FP
1 NAME 1a 2a 3a 4a 5a 160a
.
.
5 ABC NO NO
6 DEF NO NO
7 GHI NO NO NO
8 JKL NO NO
9 MNO NO NO NO
10 PQR NO NO NO



Workbook with formula:

Column A Column B Column C Column D Column E Column F
NAME Occurrence 1 Occurrence 2 Occurrence 3 Occurrence 4 Occurrence 5
1 MNO 2a
2 ABC 1a
3 PQR 1a

I can get the formula to populate Column B to get the first column header but don't know how to drag the formula across Columns C:F to return the next 4 occurrences (there may be <> 5 occurrences for each NAME). The table should then look like this:

Column A Column B Column C Column D Column E Column F
NAME Occurrence 1 Occurrence 2 Occurrence 3 Occurrence 4 Occurrence 5
1 MNO 2a 4a 5a
2 ABC 1a 4a
3 PQR 1a 3a 155a


Any help will be greatly appreciated!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Maybe something like this.
This is an array formula and must be entered with CTRL-SHIFT-ENTER.
Change ranges to match your data.
Excel Workbook
ABCDEFG
1NAME1a2a3a4a5a160a
2ABCNONO
3DEFNONO
4GHINONONO
5JKLNONO
6MNONONONO
7PQRNONONO
8
9
10NAME
11ABC1a2a
12DEF1a160a
13GHI1a4a5a
14JKL1a3a
15MNO1a2a3a
16PQR1a3a5a
Sheet
 
Upvote 0
You're welcome. Thanks for the feedback and welcome to the forum.
 
Upvote 0
excel%20help.png
Hello there,
I have almost the same situation
with a little twist

the output list is supposed to be listed vertically (in a column), not horizontally

[TABLE="width: 729"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]NAME[/TD]
[TD]1a[/TD]
[TD]2a[/TD]
[TD]3a[/TD]
[TD]4a[/TD]
[TD]5a[/TD]
[TD]160a[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]ABC[/TD]
[TD]NO[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]DEF[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]NO[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]GHI[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[TD]NO[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]JKL[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]MNO[/TD]
[TD]NO[/TD]
[TD]NO[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]PQR[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD]NO[/TD]
[TD][/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD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[TD][/TD]
[/TR]
</tbody>[/TABLE]


------------------

is there any way I can do that??
 
Upvote 0
excel%20help.png
Hello there,
I have almost the same situation
with a little twist

the output list is supposed to be listed vertically (in a column), not horizontally

[TABLE="width: 729"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]NAME[/TD]
[TD]1a[/TD]
[TD]2a[/TD]
[TD]3a[/TD]
[TD]4a[/TD]
[TD]5a[/TD]
[TD]160a[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]ABC[/TD]
[TD]NO[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]DEF[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]NO[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]GHI[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[TD]NO[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]JKL[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]MNO[/TD]
[TD]NO[/TD]
[TD]NO[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]PQR[/TD]
[TD]NO[/TD]
[TD][/TD]
[TD]NO[/TD]
[TD][/TD]
[TD]NO[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD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TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


------------------

is there any way I can do that??

Hey, I solved the problem
i found a way around it

I used your formula above, which of course worked like a charm
(MILLION thanks for that life saver :beerchug:)

I got the results in an intermediary worksheet in rows (just as you did above)

then I used a simple Index/Match to get the results in the final Columnar (vertical) fashion

AhoyNC , you are my Excel Hero !! at least till the next problem ... hehehehehe

Thanks again
 
Upvote 0
Oh please .. Do tell .....



Book1
ABCDEF
4GHINONONO
5JKLNONO
6MNONONONO
7PQRNONONO
8
9
10NAME
11ABCDEFGHIJKLMNOPQR
121a1a1a1a1a1a
132a160a4a3a2a3a
145a3a5a
Sheet1


In B12 control+shift+enter, not just enter, and copy down:

=IFERROR(INDEX($B$1:$G$1,SMALL(IF(INDEX($B$2:$G$7,MATCH(A$11,$A$2:$A$7,0),0)="no",COLUMN($B$1:$G$1)-COLUMN($B$1)+1),ROWS(A$12:A12))),"")
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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