2 way lookups, return column header, but multiple matches in row

kizzie37

Well-known Member
Joined
Oct 23, 2007
Messages
585
Office Version
  1. 365
I have a large database on the "Colated" sheet in my excel workbook:

Column E Contains Course Names
Row F1 - HZ1 Contains Role Title
The body contains either Required, Not Required or Variable

Course Name is entered into C3
H4 contains either Required, Not Required or Variable

I want to use a forumla such as the one I am using below, to return ALL the column headers applicable, e.g if the course name is in row E1 and there are 3 instances where "Required" applies, I want the 3 column headers (Role title) to be returned


The below formula will only return one match, (it is the last match in the row),
=INDEX(Colated!$F$1:$HZ$1,MATCH($H$4,INDEX(Colated!$F$2:$HZ$350,MATCH($C$3,Colated!$E$2:$E$350),)))

Can anyone advise, I think it needs an array, but im not sure how to get the multiple match returns.

thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try in I4:

=IFERROR(INDEX(Colated!$F$1:$HZ$1,SMALL(IF((Colated!$E$2:$E$350=$C$3)*(Colated!$F$2:$HZ$350=$H$4),COLUMN(Colated!$F$1:$HZ$1)-COLUMN(Colated!$F$1)+1),COLUMNS($I4:I4))),"")

confirmed with Ctrl+Shift+Enter and copied across.
 
Upvote 0
I tried this, but it comes up with a blank response, also not sure I understand the relevance of I4?. Maybe Im doing something wrong
 
Upvote 0
I tested with this sample data:


Excel 2010
EFGHIJKLMNO
1CourseRole1Role2Role3Role4Role5Role6Role7Role8Role9Role10
2Course1
3Course2RequiredRequired
4Course3
5Course1
6Course2Required
7Course3
Colated



Excel 2010
CDEFGHIJKL
3Course2
4RequiredRole2Role5Role8
Sheet1
Cell Formulas
RangeFormula
I4{=IFERROR(INDEX(Colated!$F$1:$HZ$1,SMALL(IF((Colated!$E$2:$E$350=$C$3)*(Colated!$F$2:$HZ$350=$H$4),COLUMN(Colated!$F$1:$HZ$1)-COLUMN(Colated!$F$1)+1),COLUMNS($I4:I4))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
For some reason its returning an error for me, in both the test sheet and my sheet, hence the blank
 
Upvote 0
my fault, it now works in the sample sheet, just need to figure out the issue in the main sheet. Thanks for the help
 
Upvote 0
Andrew, I finally figured out what my issue was, but I wondered, if I wanted to change it around, i.e. look up by role, then retunr the courses, what would I need to change?
 
Upvote 0
Maybe you can adapt this:


Excel 2010
ABCDEFGHIJKLMNOPQR
1CourseRole1Role2Role3Role4Role5Role6Role7Role8Role9Role10RequiredCourse1Role1Role4Role5
2Course1RequiredCourse2Role2Role5Role8Role10
3Course2RequiredRequiredCourse3Role3Role5Role7Role8Role9
4Course3RequiredRequired
5Course1RequiredRequiredRole1Role2Role3Role4Role5
6Course2RequiredRequiredCourse1Course2Course3Course1Course3
7Course3RequiredRequiredRequiredCourse1
8Course2
Sheet1
Cell Formulas
RangeFormula
N1{=IFERROR(INDEX($B$1:$K$1,SMALL(IF(($A$2:$A$7=$M1)*($B$2:$K$7=$L$1),COLUMN($B$1:$K$1)-COLUMN($B$1)+1),COLUMNS($N1:N1))),"")}
N6{=IFERROR(INDEX($A$2:$A$7,SMALL(IF(($B$1:$K$1=N$5)*($B$2:$K$7=$L$1),ROW($A$2:$A$7)-ROW($A$2)+1),ROWS(N$6:N6))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
If I wanted to amend this portion to be a range rather than an absolute, would that be possible

$B$2:$K$7=$L$1 (i.e. L1:L14)
 
Upvote 0

Forum statistics

Threads
1,224,898
Messages
6,181,625
Members
453,058
Latest member
rmd0725

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