ThisCalculator

Everyday

Search Highlight Using Conditional Formatting

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Search Highlight Using Conditional Formatting

You can highlight search results in Excel by combining conditional formatting with a formula that checks if a cell contains your search term. Enter the term in a dedicated cell, then apply a formula-based rule that references that cell, and every matching row or cell will be highlighted automatically.

Formula

The core formula used in the conditional formatting rule is:

=ISNUMBER(SEARCH($B$1, A1))

Where:

  • $B$1 – the cell containing the search term (use absolute reference so the rule applies to all cells).
  • A1 – the first cell in the range you want to highlight (relative reference, adjusts for each cell).
  • SEARCH – finds the position of the search term within the cell text; it is case-insensitive and allows wildcards.
  • ISNUMBER – returns TRUE if SEARCH finds a match (i.e., returns a number), otherwise FALSE.

If you want case-sensitive matching, replace SEARCH with FIND.

Worked Example

Suppose you have a list of fruits in cells A1:A5: Apple, Banana, Avocado, Grape, Pineapple. You type apple in cell B1.

  1. Select range A1:A5.
  2. Go to Home → Conditional Formatting → New Rule.
  3. Choose Use a formula to determine which cells to format.
  4. Enter =ISNUMBER(SEARCH($B$1, A1)).
  5. Click Format, choose a fill color (e.g., yellow), and click OK.

Result: Cells A1 (Apple) and A5 (Pineapple) are highlighted because they contain the substring “apple�. The formula returns TRUE for those cells.

When to Use This Technique

This method is ideal for quickly scanning a list or table for a keyword without using Excel’s built-in Find dialog (Ctrl+F). It is especially useful when you want to keep the highlight visible while you edit other parts of the sheet. You can also use it for:

  • Highlighting rows where a column contains a specific status (e.g., “Pendingâ€�).
  • Flagging duplicate entries (using COUNTIF instead of SEARCH).
  • Creating a live search box – type in a cell and see matches highlight instantly.

How to Set Up a Live Search Box

To make the highlight update as you type, the search term must be in a cell that the formula references. Here’s a step-by-step setup:

  1. Choose a cell for the search term, say B1.
  2. Select the data range (e.g., A2:A100).
  3. Create a new conditional formatting rule with the formula =ISNUMBER(SEARCH($B$1, A2)).
  4. Set the format (fill color, font color, etc.).
  5. Click OK. Now type any text in B1 – matching cells will highlight instantly.

Note: The formula uses relative reference for the first data cell (A2) – this is crucial. If you use an absolute reference like $A$2, the rule will only check that one cell.

Common Mistakes and Pitfalls

  • Forgetting absolute reference for the search cell – If you use B1 without $, the rule will shift when applied to other cells, and you’ll get wrong results.
  • Using SEARCH with empty search cell – If B1 is empty, SEARCH returns 1 (because empty string is found at position 1), so all cells will highlight. To avoid this, add a condition: =AND($B$1<>"", ISNUMBER(SEARCH($B$1, A1))).
  • Case sensitivity confusion – SEARCH is case-insensitive; FIND is case-sensitive. Choose based on your need.
  • Wildcards – SEARCH supports wildcards like * and ?. For example, SEARCH("a*e", A1) matches “appleâ€� and “avocadoâ€�. If you don’t want wildcards, use FIND (which does not support them).

Alternatives to Conditional Formatting

If you only need a temporary highlight, Excel’s Find feature (Ctrl+F) highlights all matches with a selected fill color, but it disappears when you close the dialog. Another alternative is using a helper column with a formula like =IF(ISNUMBER(SEARCH($B$1, A1)), "Yes", "") and then filter on that column. For more advanced needs, you can use VBA to dynamically highlight cells as you type, but conditional formatting is simpler and does not require macros.

Frequently Asked Questions

Why is my conditional formatting highlighting all cells even when the search cell is empty?

Because SEARCH(“”, A1) returns 1 (empty string is found at position 1). To prevent this, add a condition that checks if the search cell is not empty: =AND($B$1<>"", ISNUMBER(SEARCH($B$1, A1))).

How do I highlight entire rows instead of just the cell?

Select the entire row range (e.g., A2:F100) and use a formula that references the first column of the row: =ISNUMBER(SEARCH($B$1, $A2)). The dollar sign before A locks the column, so the rule checks the value in column A for each row.

Can I use this with numbers?

Yes. SEARCH works with numbers as well – Excel converts numbers to text for the search. For example, searching “12� will match cells containing 12, 123, etc. If you need exact match, use =ISNUMBER(MATCH($B$1, A1, 0)) or =EXACT(A1, $B$1).

Does this work in Google Sheets?

Yes, the same formula works in Google Sheets, but the menu path is different: Format → Conditional formatting → Custom formula is.

How do I make the highlight case-sensitive?

Replace SEARCH with FIND: =ISNUMBER(FIND($B$1, A1)). FIND is case-sensitive and does not support wildcards.

Why is my rule not working when I type a partial word?

SEARCH does partial matches by default. If you want whole-word matches, you can add spaces or use a more complex formula like =ISNUMBER(SEARCH(" "&$B$1&" ", " "&A1&" ")). This adds spaces around both the search term and the cell text to avoid matching substrings like “cat� in “concatenate�.

Related

Formula used
in search | Search term | - | apple | 0
in data | Data range (first cell) | - | A1 | 0
out match | Match found | - | IF(ISNUMBER(SEARCH(search, data)), 1, 0) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.