If Cell Contains Certain Text OR Equals Certain Text

IF cell equals certain text

IF function is frequently used in Excel worksheet to return “true value” or “false value” based on the logical test result. If you want to test values to see if they equal certain text like “abc”, you can build formula with IF function to return result.


To test if cell equals certain text, the generic formula is:

=IF(A1=”text”,”true value”,”false value”)

Formula in this example




In this example, we want to see the results of “if cell equals “abc”” for A4 and A5. Excel IF function can handle this case properly.

IF function allows you to create a logical comparison between your value and reference value (for example “A1>0”), and set true value and false value what you expect to return as test results. IF function returns one of the two results based on logical comparison result.

Syntax: IF(logica_test,[value_if_true],[value_if_false])

To test if A4 equals text “abc”, we can directly create a logical comparison A4=”abc”. “abc” should be quoted by double quotes, if missing double quotes #NAME? error displays instead and it signifies some errors should be corrected in this formula.

We set “Yes” as true result and “No” as false result, A4=”abc” is true, IF evaluates to “Yes”. Cell A5 only contains “abc” not equals “abc”, so it fails logical comparison and get a result of “No”.


IF cell contains certain text

To test if cell contains certain text like “abc”, we can use IF function together with ISNUMBER and SEARCH functions.


To test if cell contains certain text, the generic formula is:


Formula in this example:




SEARCH function can help us to see if text string A (for example “abc”) is included in another text string B (for example “abcde”), and if yes, it returns the position of the first character of the text string B.

Syntax: SEARCH(find_text,within_text,[start_number])

ISNUMBER function returns TRUE if cell contains a number, and returns FALSE if not. This function is easy to understand by its name “ISNUMBER”.

Syntax: ISNUMBER(value)



In this example, we want to know if cells in A column contain text “abc”, so we use SEARCH function to search text “abc” from cells in A column. For example, to test if A4 contains “abc”, we can build formula SEARCH(“abc”,A4), it is equivalent to SEARCH(“abc”,”abcde”).

After calculating SEARCH function, its result is delivered to ISNUMBER function as test value. In this example “abc” is found in “abcde”, and character “a” is located in the first position of all five characters, so SEARCH returns “1”, ISNUMBER(SEARCH(“abc”,”abcde”))->ISUNUMBER(1). In Excel, ISNUMBER+SEARCH can help us check if specific substring is including in string, or specific text is included in one sentence.

Formula ISNUMBER(SEARCH()) is within IF function as argument “logical_test”. Now, ISNUMBER(1) evaluates to “TRUE” and deliver “TRUE” to IF function as logical test result directly.

IF function returns result of true value “Yes”. For A5 “fghij”, it doesn’t contain “abc”, so IF returns “No” in B5.


  1. SEARCH function supports wildcards like “?” and “*”.

  1. SEARCH function is case-insensitive.
  2. IF function doesn’t support wildcards.

Related Functions

  • Excel IF function
    The Excel IF function perform a logical test to return one value if the condition is TRUE and return another value if the condition is FALSE. The IF function is a build-in function in Microsoft Excel and it is categorized as a Logical Function.The syntax of the IF function is as below:= IF (condition, [true_value], [false_value])….
  • Excel ISNUMBER function
    The Excel ISNUMBER function returns TRUE if the value in a cell is a numeric value, otherwise it will return FALSE.The syntax of the ISNUMBER function is as below:= ISNUMBER (value)…
  • Excel SEARCH function
    The Excel SEARCH function returns the number of the starting location of a substring in a text string.The syntax of the SEARCH function is as below:= SEARCH  (find_text, within_text,[start_num])…
Related Posts

Check Cell If Contains One of Many with Exclusions

In Microsoft Excel Spreadsheet or google sheets, when cells contain multiple strings, how can we accomplish this task if you want to check whether these cells contain more than one given string and exclude other given strings? In this article, ...

If Cell Contain Specific Text

This article will explain how to check if a cell contains text or a specific text string in Google Sheets or Microsoft Excel spreadsheets. In our daily work, we often look for specific text in worksheets containing large amounts of ...

Filter or Extract with a Partial Match

Assume you have a table consisting of a few cells having few values, and you want to filter out the set of records with the partial match. You might take it easy and would prefer to manually filter out the ...

Extract all Partial Matches

Just assume that you have a range of data that contains a text string and you want to extract the few partial matches into another separate range of cells; then you might think that it's not a big deal; because ...

How to Extract Text between Two Text Strings in Excel

This post will guide you how to extract text between two given text strings in Excel. How do I get text string between two words with a formula in Excel. Extract Text between Two Text Strings Assuming that you have ...