Home » excel » excel – Create list of row names based on search criteria

excel – Create list of row names based on search criteria

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have the following Excel spreadsheet:

     A            B     C        D      E            F            G        H
1                 Q1     Q2      Q3     Q4   Search criteria:     60     Asset 2
2   Asset 1       15     85      90     70                               Asset 3
3   Asset 2       40     80      45     60                               Asset 3
4   Asset 3       30     60      55     60                               Asset 5                       
5   Asset 4       12     72      25     15
6   Asset 5       60     48      27     98
7 

In Cells A1:E6 I have different assets with their performance from quarter Q1-Q4.
In Column H I want to have a list of all assets that match the search criteria in Cell G1.
In this case the search criteria is 60 which can be found in the Cells A1:E6 for the Assets 2, 3 and 5.

As you can see it can happen that the search criteria exists mutliple times in a row (like in Row 4). Therefore, I want that the asset is listed two times in the list (like Asset 3).

Do you have any idea of a formula that could create this list?

How to&Answers:

Try this in H1

=INDEX(A:A,AGGREGATE(15,7,ROW($B$2:$E$6)/($B$2:$E$6=$G$1),ROW(1:1)))

and copy down.

enter image description here


If you are using an older version of Excel this can be done with an array version of SMALL:

=INDEX(A:A,SMALL(IF($B$2:$E$6=$G$1,ROW($B$2:$E$6)),ROW(1:1)))

Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.