Google Sheets – How to Tag Cells with Multiple Tags from a List

google sheets

Alright, there's a lot of similar Q&As out there but I can't get this figured out. I'm trying to categorize the cells in column A according to the list of keywords in column B. I've tried a wide variety of excel and sheets solutions but can't seem to get this.

C2 is an example. How does one create a list of matching tags/categories based off a list?

This is the closet I've gotten:

C2: =TEXTJOIN(", ",TRUE,REPT(b$2:b$99,ISNUMBER(SEARCH(b$2:b$99,A2))))

I know there must be some kind of array formula I can plug in.

My sheet: https://docs.google.com/spreadsheets/d/1_Nnk7c7JMcacJh6r_TFCLi3FsnuPxzf5Sv-YYwcRxS8/edit?usp=sharing

enter image description here

Best Answer

Try this in C2 and copy down as far as you need:

=TEXTJOIN(", ",TRUE,ArrayFormula(IF(ISNUMBER(FIND(B$2:B$99&" ",A2&" ")),B$2:B$99,"")))

The ArrayFormula is checking to see which items from B$2:B$99 exist in the cell (i.e., tested by ISNUMBER, since anything found will have a start location and anything not found would return an error).

I've appended &" " to both the check range and the cell to check, so that "back" is not considered found in something like "backfly." If you want "back" to be considered found if it is part of a word like "backfly," just remove the concatenated space from the range and cell. However, that will also find that "hat" is part of "what," which likely isn't what you want.

Addendum 11/02/18: Be sure to see additional notes below that may apply to your situation.