Does cell A contain cell C formula/macro help

timohteee

New Member
Joined
Jul 1, 2015
Messages
13
Hello,

I have a spreadsheet right now that contains a column for a unique identifier of a file. These strings can be over 380 characters long. I have another spreadsheet that has a master list of these unique IDs some of which contain a pipe delimiter because they have multiple values within one cell.

I'll try and explain with this simple table (my data is more complex)

Table A:

Column AColumn B
cat
dog
door

<tbody>
</tbody>








Table B:

Column CColumn D
cat|lizard|ant|hamstersmall
dragon|hippo|dog|buffalobig
stove|door|microwave|televisionhome

<tbody>
</tbody>








Basically what I want is to search for the string 'cat' from Column A in Column C and then pull back Column D into Column B. So the first cell in Column B would be return the value 'small'.

Right now, I have delimited Column C and I'm running multiple VLOOKUPs (one at a time) while also using the RIGHT formula because as I said, the characters exceed the amount accepted by VLOOKUP.

Code:
=VLOOKUP("*"&RIGHT(A1,240),'[Book1.xlsx]Sheet1'!$A:$B,2,0)

If I continue with this method of delimiting the cell and running VLOOKUPs one at a time, I'll have to do at least 40 more VLOOKUPs.

Any easier way to accomplish this?
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hitimohteee
That won't work without a slight change to the data in Table B, you will need every word to be enclosed with the pip IE "cat|lizard|ant|hamster" will need to be "|cat|lizard|ant|hamster|", then this will work:-
=INDEX(Sheet1!$D:$D,MATCH("*|" &A2&"|*",Sheet1!C:C,0),1)

=index(sheet1!$D:$D This will be the range to return in table B Column D, matchMATCH("*|" &A2&"|*" A2 will be the lookup value in Table A column A &"|*",Sheet1!C:C,0),1) and Sheet1!C:C will be the list of names to search
 
Upvote 0
Thanks for your reply, Firesword. However, that doesn't fit my needs as I'm basically looking to search for the string within a cell and pull back the cell right next to it. I don't have all the values that will be within Column C from Table B nor the order they will be in.
 
Upvote 0
That formula will take the name in Table A, Column A, ie Cat and look for cat in any format in table B column C and then return the value in table B column D, is that what you were after? The reason I suggested the change is if you had Catfish in your string, and catfish was infront of cat then it would report the value of catfish and not cat. In your string all you'd need to do is make sure that you start with a | and end with a | for each item.
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

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