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

Data Analysis

  • Conditional Formatting Color Scales Examples in Excel
  • Conditional Formatting Data bars Examples in Excel
  • How to create Gauge Chart in Excel
  • How To Perform and Interpret Regression Analysis in Excel
  • How to add Trendline to a chart in Excel

References

  • How to get address of last cell in range in Excel
  • How to get first column number in range in Excel
  • How to use Excel LOOKUP Function
  • How to retrieve first match between two ranges in Excel
  • How to calculate two-way lookup VLOOKUP in Excel Table

Data Validations

  • Excel Data validation don’t exceed total
  • Excel Data validation must contain specific text
  • Excel Data validation exists in list
  • Data validation must not exist in list
  • Excel Data validation date in next 30 days

If cell contains one of many things in Excel

by

This tutorial shows how to calculate If cell contains one of many things in Excel using the example below;

Formula

{=INDEX(results,MATCH(TRUE,ISNUMBER
(SEARCH(things,A1)),0))}

Explanation

To test a cell for one of several things, and return a custom result for the first match found, you can use an INDEX / MATCH formula based on the SEARCH function.

In the example shown, the formula in C5 is:

{=INDEX(results,MATCH(TRUE,
ISNUMBER(SEARCH(things,B5)),0))}

This is an array formula and must be entered with Control + Shift + Enter.

How this formula works

This formula uses two named ranges: E5:E8 is named “things”, and F5:F8 is named “results”. Make sure you use name ranges with the same names (based on your data). If you don’t want to use named ranges, use absolute references instead.

The core of this formula is this snippet:

ISNUMBER(SEARCH(things,B5)

This is based on another formula (explained in detail here) that checks a cell for a single substring. If the cell contains the substring, the formula returns TRUE. If not, the formula returns FALSE.

Because we give SEARCH more than one thing to look for, it will give us back a list of results, in an array that looks like this:

{#VALUE!;9;#VALUE!;#VALUE!}

To simply the array, we use the  ISNUMBER function to convert all items in the array to either TRUE or FALSE. Any valid number becomes TRUE, and any error (i.e. a thing not found) becomes FALSE. The result is an array like this:

{FALSE;TRUE;FALSE;FALSE}

Which goes into the MATCH function as the “lookup_array”, with a “lookup_value” of TRUE.

MATCH then returns the position of first TRUE found (in this case is 2).

Finally, we use INDEX to retrieve a result from the named range “results” at that same position.

This approach lets you populate the “results” range with whatever values you want.

Preventing false matches

One problem with this approach with the ISNUMBER + SEARCH approach is you may get false matches from partial matches inside longer words. For example, if you try to match “dr” you may also find “Andrea”, “drank”, “drip”, etc. since “dr” appears inside these words. This happens because SEARCH automatically does a “contains-type” match.

For a quick fix, you can wrap search words in space characters (i.e. ” dr “, or “dr “) to avoid finding “dr” in another word. But this will fail if “dr” appears first or last in a cell.

If you need a more robust solution, one option is to normalize the text first in a helper column, and add a leading and trailing space. Then use the formula on this page on the text in the helper column, instead of the original text.

Post navigation

Previous Post:

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

Next Post:

Excel Data validation require unique number

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

  • IFERROR function: Description, Usage, Syntax, Examples and Explanation
  • IFS function: Description, Usage, Syntax, Examples and Explanation
  • IF with wildcards in Excel
  • How to use Excel NOT Function
  • How to use Excel FALSE Function

Date Time

  • Next biweekly payday from date in Excel
  • Get days, hours, and minutes between dates in Excel
  • HOUR function: Description, Usage, Syntax, Examples and Explanation
  • DAY function: Description, Usage, Syntax, Examples and Explanation
  • How to calculate working days left in month in Excel

Grouping

  • How to randomly assign people to groups in Excel
  • Map inputs to arbitrary values in Excel
  • Map text to numbers in Excel
  • Group times into 3 hour buckets in Excel
  • Categorize text with keywords in Excel

General

  • Zoom Worksheet in Excel
  • How to choose page/paper size in Excel before Printing
  • How to generate random number weighted probability in Excel
  • How to fill cell ranges with random number from fixed set of options in Excel
  • AutoFit Column Width, AutoFit Row Height in Excel
© 2026 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning