Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Everything about Charts in Excel
  • Reverse List in Excel
  • How To Load Analysis ToolPak in Excel
  • Calculate Conditional Percentile ‘IF’ in table in Excel
  • Use Data Form to input, edit and delete records in Excel

References

  • MATCH function: Description, Usage, Syntax, Examples and Explanation
  • Extract all partial matches in Excel
  • Last row number in range
  • How to retrieve first match between two ranges in Excel
  • How to create dynamic named range with OFFSET in Excel

Data Validations

  • Excel Data validation allow weekday only
  • Excel Data validation with conditional list
  • Excel Data validation must contain specific text
  • Excel Data validation exists in list
  • Excel Data validation whole percentage only

How to check cell that contains one of many with exclusions in Excel

by

To test a cell for one of many strings, while excluding others, you can use a formula based on the SEARCH, ISNUMBER, and SUMPRODUCT functions.

Formula

=(SUMPRODUCT(--ISNUMBER(SEARCH(include,A1)))>0)
*(SUMPRODUCT(--ISNUMBER(SEARCH(exclude,A1)))=0)

Note: this formula returns either 1 or zero, which are handled like TRUE and FALSE in formulas, conditionalĀ formatting, or data validation.

Worked Example:   Excel Data validation must contain specific text

Explanation

In the example shown the formula in C5 is:

=(SUMPRODUCT(--ISNUMBER(SEARCH(include,B5)))>0)
*(SUMPRODUCT(--ISNUMBER(SEARCH(exclude,B5)))=0)

where “include” is the named range E5:E9, and “exclude” is the named range G5:G6.

How this formula works

At the core, this formula uses the SEARCH function to look for multiple strings inside a cell. Inside the left SUMPRODUCT, SEARCH looks for all strings in the named range “include”.

Worked Example:   How to check cell equals one of many things in Excel

In the right SUMPRODUCT, SEARCH looks for all strings in the named range “exclude”.

In both parts of the formula, SEARCH returns numeric positions when strings are found, and errors when not. The ISNUMBER functions converts the numbers to TRUE and errors to FALSE, and the double negative converts the TRUE FALSE values to 1 and 0.

Worked Example:   Sum if cells contain either x or y in Excel

The result at this point looks like this:

=(SUMPRODUCT({1;0;0;0;0})>0)
*(SUMPRODUCT({0;0})=0)

Then:

=(1>0)*(0=0)
=TRUE*FALSE
=1

 

Post navigation

Previous Post:

Get day from date in Excel

Next Post:

Calculate loan interest in given year in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • NOT function: Description, Usage, Syntax, Examples and Explanation
  • Check multiple cells are equal in Excel
  • How to use Excel OR Function
  • IF with wildcards in Excel
  • OR function Examples in Excel

Date Time

  • How to calculate Next working/business day in Excel
  • YEAR function: Description, Usage, Syntax, Examples and Explanation
  • DATE function: Description, Usage, Syntax, Examples and Explanation
  • Calculate total hours that fall between two times in Excel
  • Calculate date overlap in days in Excel

Grouping

  • Group times into unequal buckets in Excel
  • If cell contains one of many things in Excel
  • Categorize text with keywords in Excel
  • Map inputs to arbitrary values in Excel
  • Map text to numbers in Excel

General

  • Select, Insert, Rename, Move, Delete Worksheets in Excel
  • How to password protect excel sheet?
  • How to generate random number between two numbers in Excel
  • Basic numeric sort formula in Excel
  • Basic error trapping example in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning