excel: how can I identify rows containing text keywords taken from a list of keywords

后端 未结 1 1003
有刺的猬
有刺的猬 2021-01-15 04:09

I have one column (call it A) of data where each cell contains a long string of words e.g.:

COLUMN A 
HORNBACH BAUMARKT ETOY, ETOY 
ALIGRO, CHAVANNES-PR 
DIP         


        
相关标签:
1条回答
  • 2021-01-15 04:35

    Assuming only 1 matching word per row at most you could use this formula in C1 copied down

    =IFERROR(LOOKUP(2^15,SEARCH(B$1:B$10,A1),B$1:B$10),"")

    IFERROR function is available in Excel 2007 or later versions only, for earlier Excel versions try this modification

    =LOOKUP("zzz",IF({1,0},"",LOOKUP(2^15,SEARCH(B$1:B$10,A1),B$1:B$10)))

    If you want to get multiple matches, in separate cells then you can use this "array formula" in C1, confirmed with CTRL+SHIFT+ENTER and copied down and across as far as you might need (commensurate with the maximum possible matches)

    =IFERROR(INDEX($B$1:$B$10,SMALL(IF(COUNTIF($A1,"*"&$B$1:$B$10&"*"),ROW($B$1:$B$10)-ROW($B$1)+1),COLUMNS($C1:C1))),"")

    If A1 contains 3 words on the list then those will be populated in C1, D1 and E1 and F1 etc. will remain blank

    Revised as per comments:

    The first range in the formula (first argument of INDEX), defines the range from which the result is taken so to change that to column Z just change that part, i.e.

    =IFERROR(INDEX($Z$1:$Z$10,SMALL(IF(COUNTIF($A1,"*"&$B$1:$B$10&"*"),ROW($B$1:$B$10)-ROW($B$1)+1),COLUMNS($C1:C1))),"")

    0 讨论(0)
提交回复
热议问题