Check whether a cell contains a substring
Categories:
How to Check if a Cell Contains a Substring in Excel

Learn various Excel formulas to efficiently determine if a cell's content includes a specific substring, covering case-sensitive and case-insensitive methods.
Checking if a cell contains a specific substring is a common task in Excel for data validation, conditional formatting, or filtering. This article will guide you through several robust methods using Excel formulas, catering to both case-sensitive and case-insensitive requirements. Understanding these techniques will significantly enhance your data manipulation capabilities in Excel.
Case-Insensitive Substring Check
For most practical scenarios, you'll want to check for a substring without worrying about capitalization. Excel's SEARCH
function is perfect for this, as it performs a case-insensitive search. If the substring is found, SEARCH
returns its starting position; otherwise, it returns a #VALUE!
error. We can combine this with ISNUMBER
to get a simple TRUE/FALSE result.
=ISNUMBER(SEARCH("substring",A1))
Basic case-insensitive check for 'substring' in cell A1
Let's break down this formula:
SEARCH("substring",A1)
: This part attempts to find "substring" within the text of cell A1. If found, it returns a number (the starting position). If not found, it returns a#VALUE!
error.ISNUMBER(...)
: This function checks if the result ofSEARCH
is a number. IfSEARCH
found the substring,ISNUMBER
returnsTRUE
. IfSEARCH
returned an error,ISNUMBER
returnsFALSE
.
flowchart TD A["Start: Check Cell A1 for 'substring'"] --> B{"SEARCH("substring", A1)"} B -- "Substring Found (e.g., 3)" --> C{"ISNUMBER(3)"} C -- "TRUE" --> D[Result: TRUE] B -- "Substring Not Found (#VALUE!)" --> E{"ISNUMBER(#VALUE!)"} E -- "FALSE" --> F[Result: FALSE]
Flowchart for case-insensitive substring check using SEARCH and ISNUMBER
"substring"
with a cell reference (e.g., B1
) if your search term is in another cell. This makes your formulas more flexible and easier to update.Case-Sensitive Substring Check
Sometimes, the case of the substring matters. For instance, you might want to distinguish between "Apple" and "apple". In such cases, you should use the FIND
function instead of SEARCH
. FIND
works identically to SEARCH
but performs a case-sensitive search.
=ISNUMBER(FIND("Substring",A1))
Case-sensitive check for 'Substring' in cell A1
The logic remains the same as with SEARCH
: FIND
returns a number if the substring is found (case-sensitively) or a #VALUE!
error if not. ISNUMBER
then converts this into a TRUE
or FALSE
boolean.
Using COUNTIF
for Substring Checks
While SEARCH
and FIND
are excellent for single-cell checks, COUNTIF
offers a powerful alternative, especially when dealing with ranges or when you need to count occurrences. COUNTIF
supports wildcards, making it versatile for substring matching.
=COUNTIF(A1,"*substring*")>0
Case-insensitive check using COUNTIF for 'substring' in cell A1
Here's how this formula works:
"*substring*"
: The asterisks (*
) are wildcards that represent any sequence of characters (including no characters). So,"*substring*"
means "any text, followed by 'substring', followed by any text".COUNTIF(A1,"*substring*")
: This counts how many cells in the range A1 contain the specified pattern. If A1 contains "substring", it returns 1; otherwise, it returns 0.>0
: We add>0
to convert the count into a booleanTRUE
(if count is greater than 0) orFALSE
(if count is 0).
COUNTIF
function is inherently case-insensitive. If you need a case-sensitive check with COUNTIF
, it becomes significantly more complex and usually involves array formulas with FIND
or EXACT
.Advanced: Checking for Multiple Substrings (OR Logic)
What if you need to check if a cell contains any of several possible substrings? You can combine the SEARCH
or FIND
method with OR
logic.
=OR(ISNUMBER(SEARCH("apple",A1)), ISNUMBER(SEARCH("orange",A1)))
Check if A1 contains 'apple' OR 'orange' (case-insensitive)
This formula checks if A1 contains "apple" OR if A1 contains "orange". If either condition is true, the formula returns TRUE
.
SUMPRODUCT
or SUM
and ISNUMBER(SEARCH(substring_list,A1))
to make the formula more concise.