If Cell Matches, Return Multiple Rows

mikec82

Board Regular
Joined
Jan 13, 2009
Messages
225
I'm working on a project that has two sheets. The first is what gets filled in manually, called "Sheet1", and looks like this:


SportWhat period(s) will they miss?What day(s) will they miss?
FootballA Period, B PeriodJune 30th, 2016
SoccerA Period, C Period, D PeriodJuly 1st, 2016

<tbody>
</tbody>


"Sheet2" is the raw data, and will actually be hidden. It looks like this:


NameSportA PeriodB PeriodC Period
John SmithFootballEnglishMathHistory
Matt RobertsSoccerMathEnglishHistory

<tbody>
</tbody>


The process I'm working on is for a sports coach to fill out Sheet1, telling me when his team will be absent. Once that is populated, I'd like to add a third Sheet that takes everyone in Sheet2 who plays that sport, and returns their name, sport, the day the will miss, and what class they have for the periods they will miss.

Let's take the example that the football team is going to miss A Period and B Period on June 30th. Here's what I would like Sheet3 to look like:

NameSportWhat day(s) will they miss?A PeriodB PeriodC Period
John SmithFootballJune 30th, 2016EnglishMath
Clayton ClarkFootballJune 30th, 2016MathScience
Ryan AustinFootballJune 30th, 2016ScienceHistory

<tbody>
</tbody>


I've got the formula below to work for Sheet3!A2, but it only works for one person. I would need it to populate more than one line, if that makes sense. Maybe I'm not using the correct functions?

=IF(ISBLANK(Sheet1!A2),"",INDEX(Sheet2!A:A,MATCH(Sheet1!A2,Sheet2!B:B,0)))
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
why are you writing a formula in A2 on sheet 3... cant you just copy the first two columns of sheet2 to sheet3?
 
Upvote 0
In Sheet3!A1, I'm wanting to return the name of the first person who plays football, according to Sheet2!B:B. In Sheet3!A2, I'm wanting the 2nd person who plays football, and so on. The coach is only inputting the team who is missing. I'm wanting to find all the people on that team in Sheet2 and put it into Sheet3.
 
Upvote 0
so basically sheet3 is only for 1 sport? Do you just hardcode "Football" into column B on sheet3?
 
Upvote 0
yeah that link looks like what you need becase essentially you need to build lists in memory. But due to the environment of writing Excel formulas, it can get complicated. I would just write a subroutine and take advantage of vba collection objects. Macros are usually the easier way to get stuff done.
 
Upvote 0
Thank you for the feedback. In this case, I'm working in Google Sheets, so that is unfortunately not an option.

This array formula below works, but it doesn't return more results when I pull the formula down. I have about 20 football players in Sheet2, so I was hoping it would show all of their names.

=ArrayFormula(IF(ISERROR(INDEX(Sheet2!D:E,SMALL(IF(Sheet2!D:E=Sheet1!$B2,ROW(Sheet2!D:E)),ROW(1:1)),2)),"",INDEX(Sheet2!D:E,SMALL(IF(Sheet2!D:E=Sheet1!$B2,ROW(Sheet2!D:E)),ROW(1:1)),2)))
 
Upvote 0
that's why i laughed at my IT department when they suggested we use google docs instead of office
 
Upvote 0
if it was me I would look into the functionality of google app script...

https://developers.google.com/apps-script/

so you can automate stuff on google sheets, id honestly rather learn that than learn how to write the formula in excel

Other people on here are better suited to help you with that formula. I always resort to vba.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,849
Messages
6,121,925
Members
449,056
Latest member
denissimo

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