In this article we will learn if cell contains word then how to assign value in Microsoft Excel 2010.
Let’s consider we have a situation where we need to review each cell and check if it contains any text. If yes, we need to return a number in a separate cell, else ignore. We can see how this is done using an example -
Column A has text containing the word “color”. 1 cell doesn’t. (The colors are not of any significance here). We need to check if each cell in this column contains the word “color”. If it does, we need to return the value 1 in column B, else we need to return 0.
To understand better, see the below screenshot:
We will use 3 functions, namely, IF, SEARCH & IFERROR to calculate the value in column B.
The If function checks whether a condition is met, and returns one value if TRUE, and another if FALSE.
The SEARCH function returns the number of the character at which a specific character or text string is first found, reading left to right (not case-sensitive)
The IFERROR function returns value_if_error if expression is an error and the value of the expression itself otherwise
In cell B2, the formula is =IFERROR(IF(SEARCH(“color”,A2),1),0)
Refer below screenshot:
In cellsA2:A8 colors of the rainbow – VIBGYOR are used. To make things different in cell A9 White is entered since White is not part of VIBGYOR.
Hence, the result is 1 in cells A2:A8 since each of those cells contain the text “color” and 0 in cell A9 since it doesn’t contain the text “color” (see blue highlighted box above).
Let us understand how the formula works:
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.