Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Conditional Formatting for Multiple Specific Texts

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To highlight a cell that contains any one of multiple specific text strings, you must use a "Formula-based" conditional formatting rule using a combination of the OR and SEARCH (or FIND) functions. Because the standard "Text that contains" option only allows for one keyword at a time, a formula is the only way to tell Excel to look for "Keyword A" OR "Keyword B" OR "Keyword C" simultaneously within a single rule.

What You'll Need

  • Microsoft Excel (Desktop version for full formula support).
  • A dataset containing the text you wish to analyze.
  • A clear list of the specific words or phrases that should trigger the formatting.

Step-by-Step

  1. Select your data range: Click and drag to highlight the cells or columns you want to format. For example, if your data is in cells A2 through A100, select that entire range.
  2. Open Conditional Formatting: Go to the Home tab on the ribbon. In the Styles group, click Conditional Formatting.
  3. Create a New Rule: From the dropdown menu, select New Rule....
  4. Choose the Formula Option: In the "New Formatting Rule" dialog box, click the last option: Use a formula to determine which cells to format.
  5. Enter the Formula: In the text box labeled "Format values where this formula is true," enter a formula using the OR and SEARCH functions.

    Example Formula: =OR(ISNUMBER(SEARCH("Apple", A2)), ISNUMBER(SEARCH("Orange", A2)), ISNUMBER(SEARCH("Banana", A2)))

    Important: Replace "A2" with the address of the very first (top-left) cell in your selected range. Replace "Apple", "Orange", and "Banana" with your specific text strings. Note that text must be enclosed in double quotation marks.
  6. Set the Format: Click the Format... button. Choose the Fill tab to select a background color, or the Font tab to change the text color. Click OK.
  7. Finalize the Rule: Click OK again to close the New Formatting Rule dialog. Your selected cells will now change color if they contain any of the specified words.

Common Mistakes

  • Using the wrong cell reference: A common error is selecting the whole column but writing the formula for cell A1 when the data actually starts at A2. The formula must reference the active cell (the first cell in the selection) for the formatting to align correctly across the range.
  • Forgetting the ISNUMBER function: The SEARCH function returns a number (the position of the text) if the word is found, and a #VALUE! error if it is not. The OR function cannot handle errors. Wrapping SEARCH in ISNUMBER converts the result to TRUE or FALSE, which the conditional formatting engine requires.
  • Case sensitivity confusion: Using SEARCH is case-insensitive (it finds both "Apple" and "apple"). If you need the formatting to be strictly case-sensitive, replace the word SEARCH with FIND in your formula.
  • Missing quotation marks: Excel treats text without quotation marks as named ranges or functions. Always wrap your search terms in "double quotes".

Tips

  • Using a Reference List: If you have a long list of keywords (e.g., 10 or more), writing a long OR formula is tedious. Instead, list your keywords in a separate range (e.g., D1:D10) and use a formula like =SUMPRODUCT(--ISNUMBER(SEARCH($D$1:$D$10, A2)))>0. This allows you to update your keywords without editing the formula.
  • Layering Rules: You can create multiple rules for the same range. For example, one rule for "High Priority" keywords (Red) and another for "Medium Priority" keywords (Yellow). Ensure the most critical rules are at the top of the list in the Manage Rules menu.
  • Combining with AND: If you want to highlight a cell only if it contains all of the specified words, replace the OR function with the AND function.

Troubleshooting

If the formatting is not appearing or is highlighting the wrong cells, try these steps in order:

  1. Check the "Applies To" range: Go to Conditional Formatting > Manage Rules. Ensure the "Applies to" range matches the cell reference used in your formula. If the range starts at A2, the formula must reference A2.
  2. Verify the formula syntax: Ensure every ISNUMBER(SEARCH("text", cell)) block is closed with its own set of parentheses and separated by a comma within the OR() function.
  3. Clear existing rules: If you have overlapping rules, they may conflict. Go to Conditional Formatting > Clear Rules > Clear Rules from Selected Cells and start the process over.
  4. Check for hidden characters: If a cell looks like it contains the word but isn't highlighting, check for leading or trailing spaces. SEARCH usually handles this, but it is good practice to ensure your data is clean.

Frequently Asked Questions

Can I use this for a very large number of words?

Yes, but the OR formula becomes difficult to manage after 5 or 6 words. For larger lists, it is better to use the SUMPRODUCT method mentioned in the Tips section, which references a separate list of cells.

Does this work for partial matches?

Yes. The SEARCH function finds the text anywhere within the cell. For example, searching for "Apple" will also highlight cells containing "Pineapple" or "Applesauce".

How do I make the formatting case-sensitive?

Replace SEARCH with FIND. While SEARCH ignores capitalization, FIND requires an exact match of uppercase and lowercase letters.

Can I highlight the entire row instead of just one cell?

Yes. In your formula, put a dollar sign before the column letter (e.g., $A2 instead of A2). This locks the reference to column A while allowing the row number to change, triggering the format for the whole row based on the value in column A.

Why is my formula returning a #VALUE! error?

Conditional formatting formulas should not display errors in the cell itself; they work in the background. If you are testing the formula in a cell and see #VALUE!, it is because the text was not found. This is why the ISNUMBER wrapper is essential—it converts that error into a "FALSE" value.