top of page

You are learning IF function in MS Excel

How do I write an IF statement to check if a cell contains specific text?

You can use a combination of the IF, SEARCH, and ISNUMBER functions in Excel to check if a cell contains specific text. Here's the formula:

`=IF(ISNUMBER(SEARCH(text_to_find, cell_reference)), "Text Found", "Text Not Found")`

Let's break down the formula:

* `IF`: This function checks a condition and returns one value if the condition is true and another value if it's false.
* `ISNUMBER(SEARCH(text_to_find, cell_reference))`: This inner part checks if the `SEARCH` function finds the `text_to_find` within the `cell_reference`.
* `SEARCH`: This function searches for a specific text string within another text string and returns the position of the first occurrence (or an error if not found).
* `ISNUMBER`: This function checks if the output from the `SEARCH` function is a number (meaning text was found) or an error (meaning text was not found).
* `"Text Found"`: This is the value returned if the `SEARCH` function finds the text. You can replace this with any text you want to display.
* `"Text Not Found"`: This is the value returned if the `SEARCH` function doesn't find the text. You can replace this with any text you want to display.

Example:

To check if cell A1 contains the text "Apple", you would use the formula:

`=IF(ISNUMBER(SEARCH("Apple", A1)), "Apple Found", "Apple Not Found")`

Notes:

* This formula is case-insensitive by default. If you need case-sensitive searching, use the FIND function instead of SEARCH.
* You can adjust the text displayed based on the outcome of the search by modifying the values within the quotation marks.

bottom of page