This formula returns TRUE when B5 contains any of the words in the named range inc and none of the words in the named range exc.
This is an array formula and must be entered with Control + Shift + Enter.
This formula relies on the AND function to test two conditions at the same time:
Count of words from named range inc is >0
Count of words from named range exc is =0
If both conditions are TRUE, the formula returns TRUE. If either condition is FALSE, the formula returns FALSE.
The test for multiple words is done using the SEARCH function with help from COUNT.
When SEARCH receives more than one item to look for, it returns an array of results, one per item. When a match is found, SEARCH returns the position of the match. When no match is found, SEARCH returns the #VALUE error. The COUNT function gets a count of numbers in the array returned by SEARCH. COUNT ignores errors by default.
In the example shown, the formula is solved in steps like this
There's no requirement that you use a range for your list of things. If you're only looking for a small number of things, you can use a list in array format, which is called an array constant. For example, to test for red, blue, or green, but exclude pink and orange, you can use:
The goal of this example is to test each cell in B5:B14 to see if it contains any of the strings in the named range things (E5:E7). These strings can appear anywhere in the cell, so this is a literal "contains" problem. The formula in C5, copied...
The key is this snippet: ISNUMBER ( SEARCH ( things , B5 ) This is based on another formula ( explained in detail here ) that simply checks a cell for a single substring. If the cell contains the substring, the formula returns TRUE. If not, the...
In this example the goal is to check a cell for several things at once, and return a comma separated list of the things that were found. In other words, we want check for the colors seen in column E and list the colors found in column C. The formula...
The SEARCH function returns the position of the search string when found, and the #VALUE! error if not found. We use this fact to test whether the search string is found by using the ISNUMBER function to "catch" valid numeric positions. ISNUMBER...
The Excel COUNT function returns a count of values that are numbers. Numbers include negative numbers, percentages, dates, times, fractions, and formulas that return numbers. Empty cells and text values are ignored.
The Excel SEARCH function returns the location of one text string inside another. SEARCH returns the position of the first character of find_text inside within_text. Unlike FIND, SEARCH allows wildcards, and is not case-sensitive.
The Excel AND function is a logical function used to require more than one condition at the same time. AND returns either TRUE or FALSE. To test if a number in A1 is greater than zero and less than 10, use =AND(A1>0,A1...
Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.