简体   繁体   中英

Excel - if cell contains text in a list then return value of another cell

I have 3 columns:

A - Lookup item
B - List
C - Link
D - formula goes here

I want to search column B for the text in each cell in column A.

For example, A2="bread" and with column B it has B2="some bread" and would return TRUE. If it's TRUE, then I want to return the value in C2="abc".

Another example, A3="eggs" and B3="egg" would return FALSE. But B4="eggs" and would return TRUE, then I want to return value in D3="ghi".

Here's an image to illustrate:

在此处输入图像描述

I can find the word in column A to any in the list in column be with this formula:

=if(countif($B$2:$B$6,"*"&A2&"*")>0,true,false)

But I can't get the right mix of INDEX and MATCH to return the contents in column C when needed. I think I need a mix of INDEX with ROW instead of MATCH.

The issue with MATCH is the 3rd argument is [match_type] which is "1= exact or next smallest(default)", "0=exact match", "-1 = exact or next largest".

Version: Excel 2016 (also would like it to work in Google Sheets but not required)

Try Match() function with wildcard matching.

=IFERROR(INDEX($C$2:$C$6,MATCH("*"&A2&"*",$B$2:$B$6,0)),FALSE)

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM