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

Data Analysis

  • Excel Frequency Function Example
  • Get column name from index in Excel Table
  • How to Sort by Color in Excel
  • What-If Analysis: Scenarios and Goal Seek in Excel
  • How To Insert and Customize Sparklines in Excel

References

  • How to get last row in numeric data in Excel
  • Basic INDEX MATCH approximate in Excel
  • Find Closest Match in Excel Using INDEX, MATCH, ABS and MIN functions
  • How to get address of last cell in range in Excel
  • How to get address of first cell in range in Excel

Data Validations

  • Data validation must not exist in list
  • Excel Data validation must begin with
  • Excel Data validation don’t exceed total
  • Excel Data validation date in next 30 days
  • Excel Data validation only dates between

Categorize text with keywords in Excel

by

This tutorial shows how to Categorize text with keywords in Excel using the example below;

Formula

{=INDEX(categories,MATCH(TRUE,ISNUMBER
(SEARCH(keywords,text)),0))}

Categorize text with keywords in Excel

Explanation

To categorize text using keywords with a “contains” match, you can use the SEARCH function, with help from INDEX and MATCH. In the example shown, the formula in C5 is:

{=INDEX(categories,MATCH(TRUE,
ISNUMBER(SEARCH(keywords,B5)),0))}

where “keywords” is the named range E5:E14, and “categories” is the named range F5:F14.

Note: this is an array formula and must be entered with control + shift  + enter.

How this formula works

At the core, this formula is using the SEARCH function to search cells in column B for every possible keyword in the named range “keywords” (E5:E14):

SEARCH(keywords,B5)

Because we are looking for multiple items (in the named range “keywords”), we’ll get back multiple results like this:

{#VALUE!;#VALUE!;#VALUE!;#VALUE!;

#VALUE!;#VALUE!;24;#VALUE!;#VALUE!;#VALUE!}

The #VALUE! error occurs when SEARCH can’t find the text. When SEARCH does get a match, it returns a number that corresponds to the position of the text inside the cell.

To change these results into a more usable format, we use the ISNUMBER function, which changes all values to TRUE/FALSE like so:

{FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE}

This array goes into the MATCH function as the lookup_array, with the lookup_value set as TRUE. MATCH then returns the position of the first TRUE it finds in the array (7 in this case) which is provided to INDEX as the row_num:

=INDEX(categories,7)

With categories as the array, and 7 as the row number, INDEX returns “Auto”.

Preventing false matches

One problem with this approach is you may get false matches from substrings that appear inside longer words. For example, if you try to match “dr” you may also find “Andrea”, “drink”, “dry”, etc. since “dr” appears inside these words. This happens because SEARCH automatically does a “contains” match.

For a quick hack, you can add space around the search words (i.e. ” dr “, or “dr “) to avoid catching “dr” in another word. But this will fail if “dr” appears first or last in a cell, or appears with punctuation, etc.

If you need a more accurate solution, one option is to normalize the text first in a helper column, taking care to also add a leading and trailing space. Then you can search for whole words surrounded by spaces.

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

  • Invoice status with nested if in Excel
  • How to return blank in place of #DIV/0! error in Excel
  • IFS function: Description, Usage, Syntax, Examples and Explanation
  • IFNA function: Description, Usage, Syntax, Examples and Explanation
  • How to use IFS function in Excel

Date Time

  • Convert date to month and year in Excel
  • MONTH function: Description, Usage, Syntax, Examples and Explanation
  • TIME function: Description, Usage, Syntax, Examples and Explanation
  • Next biweekly payday from date in Excel
  • MINUTE function: Description, Usage, Syntax, Examples and Explanation

Grouping

  • Map text to numbers in Excel
  • How to randomly assign data to groups in Excel
  • Group numbers with VLOOKUP in Excel
  • Map inputs to arbitrary values in Excel
  • Categorize text with keywords in Excel

General

  • AutoFit Column Width, AutoFit Row Height in Excel
  • How to test a range for numbers in Excel
  • Basic error trapping example in Excel
  • Excel Default Templates
  • How to Delete Cells, Row and Rows in Excel
© 2025 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning