I want to search a cell for a list of words. I thought this would work as an array formula:
{=FIND(<list of words I want to search for>,<cell I want to search>)}
But it only finds a match when a word that's in the cell I'm searching sits in the first row of the list of words I'm searching for. Is there any way to write a formula that looks through the entire list? And I'd prefer if it didn't just return TRUE/FALSE. I know how to search cell for a list of words and return TRUE/FALSE based on whether or not a word in the list exists in the cell. I want to actually know which word was found, or its position.
Adding this answer for people like me for whom a TRUE/FALSE answer is perfectly acceptable
or case-sensitive
Where the range for the search terms is
G1:G7
Remember to press CTRL+SHIFT+ENTER
This will return the matching word or an error if no match is found. For this example I used the following.
List of words to search for:
G1:G7
Cell to search in:
A1
Enter as an array formula by pressing Ctrl+Shift+Enter.
This formula works by first looking through the list of words to find matches, then recording the position of the word in the list as a positive value if it is found or as a negative value if it is not found. The largest value from this array is the position of the found word in the list. If no word is found, a negative value is passed into the
INDEX()
function, throwing an error.To return the row number of a matching word, you can use the following:
This also must be entered as an array formula by pressing Ctrl+Shift+Enter. It will return
-1
if no match is found.{=FIND("cell I want to search","list of words I want to search for")}
{=SUM(FIND($A$1:$A$100&"|";A3))}
this ensures spreadsheet will compare strings like "cellvlaue|" againts "pattern1|", "pattern2|" etc. which sorts out conflicts like pattern1="newly added", pattern2="added" (sum of all cells matching "added" would be too high, including the target values for cells matching "newly added", which would be a logical error)