Go Back

How to Check if a Range Contains One of Many Substrings

We can check if a range of cells contains one of many substrings with the SUMPRODUCT and COUNTIF functions. This article will walk through the process.

Figure 1: How to Check if a Range of Cells Contains One of Many Substrings

Formula

=SUMPRODUCT(COUNTIF(A4:A9,{"*Rome*";"*Giant*";"*Five*"}))>0

Setting up the Data

  • We will input the data into the table as shown in figure 2
  • We will check the range (A4:A9) if they contain any of the substrings in B4:B6

Figure 2: Data to Check if a Range of Cells Contains One of Many Substrings

Check if a Range of Cells Contains One of Many Substrings

  • We will click on Cell C4
  • We will input the formula below into the cell

=SUMPRODUCT(COUNTIF(A4:A9,{"*Rome*";"*Giant*";"*Five*"}))>0

  • We will press the enter key to get the result

Figure 3: Result for the Range of Cells Showing that it Contains Rome and Giant

Explanation

The COUNTIF function counts the contents of the substrings that appear within the chosen RANGE (A4:A9). Because the COUNTIF function is laden with multiple values to search for, every count for a value is received in the form of 0 and 1.

The SUMPRODUCT function returns as TRUE any value that is greater than ZERO.

Instant Connection to an Expert through our Excelchat Service

Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.

Did this post not answer your question? Get a solution from connecting with the expert.

Another blog reader asked this question today on Excelchat:
Here are some problems that our users have asked and received explanations on

If range of cell contains X, count then if range of cell contains Y
Solved by D. A. in 15 mins
I have a database - one sheet contains two identifiers for each patient. Another contains many rows of data with one of the identifiers and multiple datapoints. I need to get the second identifier into the second sheet whenever the first identifier matches the one in the first sheet.
Solved by C. F. in 22 mins
I need a formula that will count one column/range that contains the number 10 but only if there is an "x" in a different column/range
Solved by T. J. in 22 mins

Leave a Comment

avatar