简体   繁体   中英

If column B cell value contains A cell value

I have two columns A and B in excel and I want third column output to be like show below

    A    B         C
    -------------------
    a |  sd      | a.com
    d |  a.com   |
    f |  g.in    |
    g |  ad      | g.in

B column has 'a.com'which contains 'a.' so C column it displays a.com .B column doesnt have which contains 'd.' so column cell is empty and so on..

Put the following formula in column C:

=IFERROR(INDEX($B$1:$B$4,MATCH(A1,LEFT($B$1:$B$4,SEARCH(".",$B$1:$B$4)-1),0)),"")

It is an array formula, so press Ctrl - Shift - Enter instead of Enter when entering it.

Try this formula in C1 copied down

=IFERROR(VLOOKUP(A1&".*",B$1:B$4,1,0),"")

IFERROR function only works in Excel 2007 or later - for earlier excel versions try

=LOOKUP("zzz",IF({1,0},"",VLOOKUP(A1&".*",B$1:B$4,1,0)))

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