Log in  \/ 
x
or
x
x
Register  \/ 
x

or

Excel Formula: Check if cell contains one of many things

This tutorial provides a formula to check if a cell contains one of several values in Excel, and explains the arguments in the formula and how the formula work.
doc check if contain one of things 1

Generic formula:

=SUMPRODUCT(--ISNUMBER(SEARCH(things,text)))>0

Arguments

Things: the values you want to check if cell contains one of them.
Text: the cell reference or text string you want to check if contains number.

Return value:

This formula returns logical value, FALSE: the cell does not contain any one of the things; TRUE:the cell contains at least one of things.

How this formula work

For instance, you want to check if the cell B3 contains number, please use below formula

=SUMPRODUCT(--ISNUMBER(SEARCH($E$3:$E$5,B3)))>0

Press Enter key to check.
doc check if contain one of things 2

Explanation

SEARCH function: the SEARCH function returns the location of the first character of the text string inside another. If the SEARCH function finds the matched text, it returns the relative position, if not, it returns #VALUE! error. For instance, here the formula SEARCH($E$3:$E$5,B3) will search each value of the range E3:E5 in cell B3, and returns the location of each text string in the cell B3. It will return an array result as this: {18;#VALUE!;#VALUE!}.
doc check if contain one of things 3

ISNUMBER function: the ISNUMBER function returns TRUE when a cell contains a number. So ISNUMBER(SEARCH($E$3:$E$5,B3)) will return array result as {true,false,false} as the SEARCH function finds 1 number.
doc check if contain one of things 4

--ISNUMBER(SEARCH($E$3:$E$5,B4)) converts the TRUE value to 1, and converts FALSE value to 0, so this formula convert the array result to {1;0;0}.
doc check if contain one of things 5

SUMPRODUCT function: is used to multiples ranges or sum arrays together and returns the sum of products. The SUMPRODUCT(--ISNUMBER(SEARCH($E$3:$E$5,B3))) returns 1+0+0=1.

At last, compare left formula SUMPRODUCT(--ISNUMBER(SEARCH($E$3:$E$5,B3))) and 0, as long as the result of left formula is greater than 0, the formula will return TRUE, or it will return FALSE.
doc check if contain one of things 6

Sample File

doc sampleClick to download sample file


Relative Formulas

  • Check if a cell contains a specific text
    To check if a cell contains some texts in range A but does not contain the texts in range B, you can use an array formula which combines the COUNT, SEARCH and AND function in Excel
  • Check if a cell contains one of several values but exclude other values
    This tutorial will provide a formula to quickly handle the task that check if a cell contains one of things but excluding other values in Excel and explain the arguments of the formula.
  • Check if cell contains one of things
    Supposing in Excel, there is a list of values in column E, you want to check if the cells in column B contain all of the values in column E, and return TRUE or FALSE.
  • Check if cell contains number
    Sometimes, you may want to check if a cell contains numeric characters. This tutorial provides a formula which will return TRUE if the cell contains number, FALSE if cell does not contain number.

The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.