Search for a value in multiple non-adjacent columns and retrieve an array with all values of the 1st column where there was a match in that row.

Solvap

New Member
Joined
Sep 17, 2015
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hello Everyone,

I hope someone can help me out on this one. It's been a week now and I still cannot get it to work properly.

Suppose the following data-set (dummy data)

Needed valuesColumn1Column2Column3Column4Column5Column6
AtRow01ID-38-86emailID-06-936phoneID-29-381email1
AtRow02ID-47-109et@yahoo.orgID-24-6011-673-487-3587ID-42-488gravida.mauris@google.ca
AtRow03ID-84-277euismod.est@protonmail.netID-95-666(725) 482-8987ID-03-981vitae@outlook.ca
AtRow04ID-03-651felis.purus@outlook.caID-62-9871-308-684-8517ID-79-966at.fringilla@yahoo.ca
AtRow05ID-82-284tempor.lorem.eget@protonmail.orgID-94-8081-811-323-7166ID-80-429est.vitae@icloud.com
AtRow06ID-62-738leo.cras.vehicula@aol.caID-04-612(409) 724-7091ID-02-488eu.placerat.eget@yahoo.org
AtRow07ID-71-278massa.vestibulum@google.coukID-82-731(482) 777-6082ID-12-799pharetra.nibh@hotmail.edu
AtRow08ID-29-418etiam@icloud.coukID-49-8871-363-761-5973ID-77-275hendrerit.neque@yahoo.ca
AtRow09ID-22-636magna.nam@hotmail.coukID-19-2251-984-889-6786ID-04-330velit@yahoo.couk
AtRow10ID-29-299augue.malesuada@google.coukID-72-252(458) 436-3484ID-78-14eget.nisi@aol.edu

What I'm looking for is to "TextJoin" all Needed values, sorted, where the 5 first characters of an ID matched in any column as here-after:

ABC
IDsWhat I am looking forWhat I get with my current formula
ID-02AtRow06AtRow06
ID-03AtRow03, AtRow04AtRow04, AtRow03
ID-04AtRow09AtRow06, AtRow09
ID-12AtRow07AtRow07
ID-19AtRow09AtRow09
ID-24AtRow02AtRow02
ID-29AtRow01, AtRow08, AtRow10AtRow08, AtRow10, AtRow01

As you can see, the string "ID-02" is only found in Column5 and the value in the 1st column, "AtRow06", is retrieved.
"ID-03" is found 2 times, in Column5 so we retrieve AtRow03 on the same row from 1st column and in Column1 so we retrieve AtRow04 on the same row from 1st column.

I've come to the following function, which seems to work but I can't get it to be sort each value. So far, I get unsorted values "AtRow04, AtRow03" instead of "AtRow03, AtRow04".

C1=TEXTJOIN(", ",TRUE,FILTER($A$2:$A$11,LEFT($B$2:$B$11,5)=I2,""),FILTER($A$2:$A$11,LEFT($D$2:$D$11,5)=I2,""),FILTER($A$2:$A$11,LEFT($F$2:$F$11,5)=I2,""))
C2=TEXTJOIN(", ",TRUE,FILTER($A$2:$A$11,LEFT($B$2:$B$11,5)=I3,""),FILTER($A$2:$A$11,LEFT($D$2:$D$11,5)=I3,""),FILTER($A$2:$A$11,LEFT($F$2:$F$11,5)=I3,""))
and so on.

I'm also wondering if there is a way to search for a specific value in multiple columns and, when there is a match, put the left most values (from 1st column) into an array, then look for the following match and so on ?


Btw, I'm using Excel from Office 365 and I'm not allowed to use Excel Table, Named ranges nor VBA ?

Any help is more than welcome.
Thanks in advance.
Solvap
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
How about:

Excel Formula:
=TEXTJOIN(", ",TRUE,SORT(FILTER(A$2:A$11,MMULT(--(LEFT(B$2:F$11,5)=I2),{1;0;1;0;1}))))
 
Upvote 0
Solution
TEXTJOIN(", ",TRUE,SORT(FILTER(A$2:A$11,MMULT(--(LEFT(B$2:F$11,5)=I2),{1;0;1;0;1}))))
Hello Eric W,

Thank you soooo much. It's the first time I see that MMULT function. I'll dig into it, very interesting (y)
It works super

Thank you again, I will finally get some time to sleep
Solvap
 
Upvote 0

Forum statistics

Threads
1,215,528
Messages
6,125,342
Members
449,218
Latest member
Excel Master

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