match 2 criteria and return multiple rows

tryzhas

New Member
Joined
Feb 18, 2015
Messages
4
Hello,

I'm trying to find out a solution (macro/formula) for matching 2 criteria and return multiple rows.

I have predefined Matrix table with all data:

ABCDE
1Header1Header2Header3Header4
2Text1xx
3Text2xxx
4Text3xx
5Text4x

<tbody>
</tbody>

and for separate sheet I need to select which Text belongs to respective Header.

So if I select Header1 (column B) i'll get as result all rows, where is "x" in column B
like this:

A
1Text1
2Text2
3Text4

<tbody>
</tbody>

and similar way for "header2
A
1Text1
2Text4
3

<tbody>
</tbody>

etc.

i did it once a years ago, but it wasnt a nice/elegant solution (many formulas, macros...no option for skip rows without "x"...etc) + it was really hard to update data (not mention it was hard for me, not for common user)

Actually I'm trying to create something simple, which will be easy to manage (data + formulas/macro)

any ideas here guys/ladies?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Assuming the table is in Sheet4 Range A2:A5 you can try this...


Book1
ABCDE
1Header1Header2Header3Header4
2Text1xx
3Text2xxx
4Text3xx
5Text4x
Sheet4


ABC
1Text1Header22
2Text3
3
4

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet5

Worksheet Formulas
CellFormula
C1=COUNTIF(INDEX(Sheet4!$B$2:$E$5,,MATCH(B1, Sheet4!$B$1:$E$1, 0)), "x")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
A1{=IF(ROW()>$C$1, "", INDEX(Sheet4!$A$2:$A$5, SMALL(IF(INDEX(Sheet4!$B$2:$E$5,,MATCH($B$1, Sheet4!$B$1:$E$1, 0))="x", ROW($A$2:$A$5)), ROWS($A$1:A1))-1))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Last edited:
Upvote 0
Row\Col
A​
B​
C​
D​
E​
H​
1​
Header1 Header2 Header3 Header4 Header1
2​
Text1 x x
3​
3​
Text2 x x xList
4​
Text3 x xText1
5​
Text4 x Text2
6​
Text4
7​

In H2 just enter:

=COUNTIFS(INDEX(B2:E5,0,MATCH(H1,B1:E1,0)),"x")

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

=IF(ROWS($H$4:H4)>$H$2,"",INDEX($A$2:$A$5,SMALL(IF(INDEX($B$2:$E$5,0,MATCH(H$1,$B$1:$E$1,0))="x",ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($H$4:H4))))
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,956
Members
449,096
Latest member
Anshu121

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