• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

check if string is contained in other

I have 2 sheets.

one sheet has a column of names say Alex, Bob, Chad.

I have another sheet with 2 columns:
1st Column has names Alex Michael, Chad Rogers, Bob Stevens,
2nd column has codes: 009, 007, 003, etc...

Now I would like to check if a name in sheet1 is contained in sheet2 and paste its corresponding code next to it

so sheet1 should look like

Alex 009
Bob 003
Chad 007

How do I do so?

Thanks
 
I don't think vlookup will work as vlookup will give results even for partial matches which can be a disaster. I think it can be done with SEARCH and SUMPRODUCT but I can't seem to get it done
 
@joharmenezes

Not sure what you are trying but you can try this

Code:
=IFERROR(VLOOKUP(A1&"*",Sheet3!$A$1:$B$3,2,FALSE),"")

or

Code:
=IFERROR(VLOOKUP("*"&A1&"*",Sheet3!$A$1:$B$3,2,FALSE),"")

for your knowledge i attached the sample file

Hope it will solve other wise please inform

Thanks
 

Attachments

  • Match With String.xlsx
    9.1 KB · Views: 9
Last edited:
@joharmenezes

Use this formula

Code:
=INDEX(Sheet3!$B$2:$B$5,SMALL(IF(Sheet2!A2=MID(Sheet3!$A$2:$A$5,1,FIND(" ",Sheet3!$A$2:$A$5,1)-1),ROW(Sheet3!$A$2:$A$5)-ROW(Sheet3!$A$2)+1),1))

I had extracted data on sheet 2 and my main data is in sheet 3. You can change the reference as per your req.

Tell me if this works as you need.

Somendra.
 
Hi sgmpatnaik your formula is working. I didn't know that u could use a "*" in vlookup. Thanks.

Hi Somendra I have not tested your formula but I think it should work. Regarding your query, no there is only 1 alex. but thanks anyway
 
Back
Top