Extract Comma-Separated Matches Based on Multiple Criteria and Order Preservation

sobuj53

New Member
Joined
Jan 16, 2014
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have a dataset with four columns (A:D) and a cell (E5) containing comma-separated values. I need to extract all matching values from column B that meet specific criteria while preserving the order presented in cell E5.
ABCD
201-0012
301-0011This
401-0013
101-00102This
101-0045zInfThis
701-0016
701-0014This

Now in Cell E5 I have following value: 1, 3
I'm trying to match each value of E5 with column A, while the corresponding value of column D should contain "This" and Column C should not contain "zInf" and then return all matching value from column B.
The output should look like: 01-00102, 01-0014 , 01-0011. I have following formula,
Excel Formula:
=TEXTJOIN(", "; TRUE; FILTER(B1:B7; (ISNUMBER(MATCH(A1:A7; FILTERXML("<t><s>" & SUBSTITUTE(E5; ", "; "</s><s>") & "</s></t>"; "//s"); 0))) * (D1:D7="This") * (C1:C7<>"zInf")); "")

However this formula sorts the returned value, so I'm getting 01-0011, 01-00102, 01-0014 instead of 01-00102, 01-0014 , 01-0011. I need the retuned value in order they appear in Cell E5.

I have anther formula
Excel Formula:
=TEXTJOIN(", "; TRUE; INDEX(B1:B7; MATCH(FILTERXML("<t><s>" & SUBSTITUTE(E5; ", "; "</s><s>") & "</s></t>"; "//s"); IF((D1:D7="This")*(C1:C7<>"zInf"); A1:A7; ""); 0)))

this formula works but it only returns the first matching value, not all matching value from column B.


I'd really appreciate if someone could help me out in this matter. Thank you.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,223,952
Messages
6,175,595
Members
452,657
Latest member
giadungthienduyen

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