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

Data Analysis

  • Error Bars in Excel
  • How To Create Pareto Chart in Excel
  • Create Scatter Chart in Excel
  • How To Compare Two Lists in Excel
  • How to create Gauge Chart in Excel

References

  • How to get last column number in range in Excel
  • Count rows that contain specific values in Excel
  • How to get relative row numbers in a range in Excel
  • How to use Excel COLUMN Function
  • To count total rows in a range in Excel

Data Validations

  • Excel Data validation require unique number
  • Excel Data validation with conditional list
  • Excel Data validation exists in list
  • Excel Data validation must not contain
  • Excel Data validation specific characters only

How to check if cell contains some words but not others in Excel

by

To test a cell to see if contains certain words but not others, you can use an array formula based on the COUNT and SEARCH functions, wrapped in the AND function.

Formula

{=AND(COUNT(SEARCH(inc,A1))>0,COUNT(SEARCH(exc,A1))=0)}

Explanation

In the example shown, the formula in C5 is:

{=AND(COUNT(SEARCH(inc,B5))>0,COUNT(SEARCH(exc,B5))=0)}

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.

How this formula works

This formula relies on the AND function to test two conditions at the same time:

  1. Count of words from named range inc is >0
  2. 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

=AND(COUNT({1;11;#VALUE!})>0,COUNT({#VALUE!;#VALUE!})=0)
=AND(2>0,0=0)
=AND(TRUE,TRUE)
=TRUE

With hard-coded values

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:

=AND(COUNT(SEARCH({"red","blue","green"},B5))>0,COUNT(SEARCH({"orange","pink"},B5))=0)

This version does not require the control + shift + enter array formula syntax.

Post navigation

Previous Post:

DECIMAL function: Description, Usage, Syntax, Examples and Explanation

Next Post:

AVERAGE function: Description, Usage, Syntax, Examples and Explanation

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

  • How to return blank in place of #DIV/0! error in Excel
  • OR function Examples in Excel
  • Check multiple cells are equal in Excel
  • Excel If, Nested If, And/Or Criteria Examples
  • AND function: Description, Usage, Syntax, Examples and Explanation

Date Time

  • Add decimal minutes to time in Excel
  • Get work hours between dates in Excel
  • NOW function: Description, Usage, Syntax, Examples and Explanation
  • YEAR function: Description, Usage, Syntax, Examples and Explanation
  • Get last day of month in Excel

Grouping

  • Calculate conditional mode with criteria in Excel
  • Group numbers at uneven intervals in Excel
  • Group numbers with VLOOKUP in Excel
  • Running count group by n size in Excel
  • If cell contains one of many things in Excel

General

  • Basic numeric sort formula in Excel
  • Convert column letter to number in Excel
  • Count cells that do not contain many strings in Excel
  • 3D SUMIF for multiple worksheets in Excel
  • AutoRecover file that was never saved in Excel
© 2026 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning