Identify value of ordered list within a cell

bm661

New Member
Joined
Oct 5, 2016
Messages
2
I have two cells (A1 and B1) which consist of lists where the values are separated by commas. I would like to be able to enter a term found in B1 and pull its corresponding value from A1.

For example

A1B1C1D1
San Jose, Paris, Nova Scotia, TokyoCosta Rica, France, Canada, JapanCanadaNova Scotia

<tbody>
</tbody>

In C1 I can enter Canada and D1 will return Nova Scotia. If there are multiple Canadas within B1 it is fine to pull the first corresponding instance. The number of items in column A will always equal the number of items in column B.

With
=SUBSTITUTE(MID(SUBSTITUTE("," & A1&REPT(" ",6),",",REPT(",",255)),E1*255,255),",","")

where E1 = 3 since I know Canada is the third item in the list. Would there be a way with a formula to determine Canada's position within that list?

I would like to avoid text to columns since the number of items within each lists varies and I would not know how many columns to allocate in the rest of the sheet. I would also prefer not to use VBA. Thank you!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Something like this


Excel 2010 32 bit
ABCDE
1San Jose, Paris, Nova Scotia, Tokyo, Abuja, Brussels, MoscowCosta Rica, France, Canada, Japan, Nigeria, Belgium, RussiaBelgiumBrussels6
Sheet4
Cell Formulas
RangeFormula
D1=TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",90)),1+90*(E1-1),90))
E1=ROUNDUP(SEARCH(C1,SUBSTITUTE(B1,",",REPT(" ",90)))/90,0)
 
Upvote 0

Forum statistics

Threads
1,214,895
Messages
6,122,128
Members
449,066
Latest member
Andyg666

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