Lookup multiple values in a single cell (separated by commas) and then return the values to a single cell

MJD5241

New Member
Joined
Mar 10, 2017
Messages
2
**XCEL FILE ATTACHED**

Question: If I have a workbook with 2 tables; 1 has the data that I want to search and 1 is empty and where I would like the "searched" values output, what lookup formula would I need to use?.
  • The attached file is a list of companies in one column and the states in which they have locations in the adjacent column

  • Each company has multiple states where they have locations (For each company, these are separated by semi-colons For Ex: TX; CA; MA; NY)

  • I want to search, for ex, MA and have it output all the different companies that have MA locations


THIS IS THE TABLE I WANT TO SEARCH:

CompaniesState Locations
Company 1
TX; CA; AZ; IL; VA; OH; MI; MX; Canada

<tbody>
</tbody>
Company 2
IL; MA; PR

<tbody>
</tbody>
Company 3
AL; AK ; AZ; AR; CA; CO; CT; DC; DE; FL; GA; HI; ID; IL; IN; IA; KS; KY; LA; ME; MD; MA; MI; MN; MS; MO; MT; NE; NV; NH; NJ; NM; NY; NC; ND; OH; OK; OR; PA; RI; SC; SD; TN; TX; UT; VT; VA; WA; WV; WI; WY

<tbody>
</tbody>
Company 4
CA; TX; PA; NJ; Italy

<tbody>
</tbody>

<tbody>
</tbody>


THIS IS THE TABLE I WANT TO OUTPUT TO:

MACANYNJ
company name with with MA site would go here
company name with with CA site would go here

<tbody>
</tbody>
...and so on

<tbody>
</tbody>
...and so on

<tbody>
</tbody>
company name with with MA site would go here

<tbody>
</tbody>
company name with with CA site would go here

<tbody>
</tbody>

<tbody>
</tbody>
company name with with MA site would go here

<tbody>
</tbody>
company name with with CA site would go here

<tbody>
</tbody>

<tbody>
</tbody>
company name with with MA site would go here

<tbody>
</tbody>
company name with with CA site would go here

<tbody>
</tbody>

<tbody>
</tbody>
...and so on
...and so on

<tbody>
</tbody>

<tbody>
</tbody>

 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try something along the lines of this:


Excel 2010
ABCDEFG
1CompaniesState LocationsMACANYNJ
2Company 1TX; CA; AZ; IL; VA; OH; MI; MX; CanadaCompany 2Company 1Company 3Company 3
3Company 2IL; MA; PRCompany 3Company 3Company 4
4Company 3AL; AK ; AZ; AR; CA; CO; CT; DC; DE; FL; GA; HI; ID; IL; IN; IA; KS; KY; LA; ME; MD; MA; MI; MN; MS; MO; MT; NE; NV; NH; NJ; NM; NY; NC; ND; OH; OK; OR; PA; RI; SC; SD; TN; TX; UT; VT; VA; WA; WV; WI; WYCompany 4
5Company 4CA; TX; PA; NJ; Italy
6
Sheet1
Cell Formulas
RangeFormula
D2{=IFERROR(INDEX($A$2:$A$5,SMALL(IF(ISNUMBER(FIND(D$1,$B$2:$B$5)),ROW($A$2:$A$5)-1),ROWS($A$1:$A1))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
CellFormula
D2{=IFERROR(INDEX($A$2:$A$5,SMALL(IF(ISNUMBER(FIND(D$1,$B$2:$B$5)),ROW($A$2:$A$5)-1),ROWS($A$1:$A1))),"")}

<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>

[/QUOTE]



When I used this formula on the actual sheet (formatted EXACTLY the same, only it has 1,996 companies versus 5 in the ex) it misses quite a few. It only identifies 8 where there are at least 50.

Any guidance?
 
Upvote 0
First off, make sure that you adjust the ranges in the formula to fit the data in the actual sheet (i.e. $A$5 will become $A$1997 or whatever you last row of data is).

The formula should grab all exact matches from row 1. How it is right now, it is case sensitive due to the FIND function. This can be changed to SEARCH to make it not case sensitive (i.e. NY and ny will be seen as matches).

Make sure that you confirm the formula using Ctrl Shift Enter.
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

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