In this article you will teach yourself how to search for string in column. You may need this trick when you want to check if the cell contains string you need.
Search for the string in cells
In this example you want to check if the cell contains either "text" or "string". You will apply the formula to find string and substring in entire column.
In the data table below you see how data looks like.
To check if "text" or "string" exist just use this formula:
This formula will display TRUE or FALSE in B column. No matter if it was a whole word or just a substring.
You can use conditional formatting if you want.
Extracting first/nth/last word from the string
Let's see now how to extract the first, the nth or the last word from the string.
Suppose you have some string in A2 cell. You want to extract some part of this string. To do this you need to use formulas below.
To extract the first word from the string just use this formula:
You may also extract the first word from the string with a leading space:
This is a formula which let you extract the nth word. You string is A1 cell and the number of occurence is in B1.
=TRIM(RIGHT(SUBSTITUTE(LEFT(TRIM(A2),FIND("^^",SUBSTITUTE(TRIM(A2)&" "," ","^^",B2))-1)," ",REPT(" ",100)),100))
And finally the last word you can extract with below Excel formula:
=IF(ISERR(FIND(" ",A2)),"",RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2," ","*",LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))))
Hope this article helped you.