The fastest way to apply conditional formatting based on text in Excel is to select your data, go to Home > Conditional Formatting > Highlight Cells Rules > Text that Contains, enter the word or phrase, and pick a format. For more control, use a formula like =ISNUMBER(SEARCH("text",A1)) in a new rule to highlight cells that contain specific text, or =EXACT(A1,"text") for case-sensitive matches. This article explains both methods, how to write your own formulas, and common pitfalls.
Why Conditional Formatting with Text Is Different
Conditional formatting for numbers often uses simple rules like “greater than” or “between.” Text is trickier because Excel must decide whether a cell contains a word, starts with it, ends with it, or matches it exactly. The built-in “Text that Contains” rule only checks for a substring anywhere in the cell, and it is not case-sensitive. If you need more specific logic—like highlighting only cells that start with “Urgent” or that match “Paid” exactly—you must write a formula. Formulas also let you compare text across columns, such as highlighting a row when a cell in another column contains a certain word.
Using the Built-in “Text that Contains” Rule
This is the quickest method for a simple contains check. Steps:
- Select the range of cells you want to format (e.g.,
A2:A100). - Go to Home > Conditional Formatting > Highlight Cells Rules > Text that Contains.
- In the dialog box, type the text you want to find (e.g., “Overdue”).
- Choose a format from the dropdown (like “Light Red Fill with Dark Red Text”) or click “Custom Format” to set your own.
- Click OK.
This rule uses the SEARCH function internally, so it ignores case. It will highlight any cell that contains “Overdue” anywhere—including “Overdue!” or “Not Overdue”. That last one is a common gotcha: the word “Not” before “Overdue” still gets highlighted because the rule only looks for the substring.
Writing a Formula for Exact Matches
If you need an exact match (case-insensitive), use the EXACT function, which is case-sensitive by default. For a case-insensitive exact match, combine EXACT with UPPER or LOWER.
Example: Highlight cells in A2:A100 that equal “Paid” exactly (not “Paid ” or “paid”).
- Select
A2:A100. - Go to Home > Conditional Formatting > New Rule.
- Choose “Use a formula to determine which cells to format”.
- Enter:
=EXACT(A2,"Paid") - Click Format, choose a fill color, and click OK twice.
This formula returns TRUE only when the cell content is exactly “Paid” with the same capitalization. If you want case-insensitive exact match, use =UPPER(A2)="PAID".
Case-Sensitive Contains and Starts/Ends With
For a case-sensitive “contains” check, use FIND instead of SEARCH. FIND is case-sensitive but returns an error if the text is not found, so wrap it in ISNUMBER.
Example: Highlight cells in B2:B50 that contain “Urgent” (capital U) anywhere.
- Select
B2:B50. - New Rule > Use a formula.
- Enter:
=ISNUMBER(FIND("Urgent",B2))
To highlight cells that start with “Urgent”, use =LEFT(B2,6)="Urgent". To highlight cells that end with “done”, use =RIGHT(B2,4)="done". These are case-sensitive; add UPPER or LOWER to ignore case, e.g., =LEFT(LOWER(B2),6)="urgent".
Highlighting Entire Rows Based on Text
Often you want to highlight a whole row when a specific column contains a keyword. The trick is to use a mixed reference: lock the column letter but let the row change.
Example: Highlight rows in A2:D100 where column B contains “Overdue”.
- Select the entire range
A2:D100(make sure A2 is the active cell). - New Rule > Use a formula.
- Enter:
=$B2="Overdue"(exact match) or=ISNUMBER(SEARCH("Overdue",$B2))(contains). - Set a format and click OK.
The dollar sign before B locks the column, so the rule applies to column B for each row, but the row reference is relative, so it works for every row in the selection.
Common Problems and How to Fix Them
- Rule applies to the wrong range: Check the “Applies to” box in the Conditional Formatting Rules Manager. It should match your selected range.
- Formula returns an error: If you use
FINDwithoutISNUMBER, cells without the text show#VALUE!and the rule may not work. Always wrapFINDinISNUMBER. - Case sensitivity surprises: The built-in rule and
SEARCHare case-insensitive. UseFINDorEXACTwhen case matters. - Leading/trailing spaces: A cell with “Paid ” (trailing space) won’t match
EXACT. Use=TRIM(A2)="Paid"to ignore spaces. - Rule order: If you have multiple rules, the first rule in the list takes precedence. Use the Rules Manager to reorder or check “Stop If True”.
Frequently Asked Questions
How do I highlight cells that contain multiple different words?
Use the OR function in a formula. For example, to highlight cells containing “red” or “blue”: =OR(ISNUMBER(SEARCH("red",A2)),ISNUMBER(SEARCH("blue",A2))). This works for any number of words.
Can I use wildcards like * or ? in conditional formatting?
Yes, but only in the built-in “Text that Contains” rule if you type them directly, or in formulas using COUNTIF or MATCH. For example, =COUNTIF(A2,"*urgent*")>0 is equivalent to a contains check. Wildcards do not work with SEARCH or FIND—those treat them as literal characters.
Why is my formula not working when I copy it to other cells?
Check your cell references. If you use A2 without a dollar sign, the rule adjusts relative to the active cell. For a single column, that’s fine. For rows, you need to lock the column with $A2. Also ensure the “Applies to” range is correct.
Does conditional formatting work in Excel for the web or Mac?
Yes, the same features exist in Excel for Microsoft 365 on Windows, Mac, and the web. The menu paths are identical. On Mac, keyboard shortcuts differ (e.g., Cmd instead of Ctrl), but the formulas and rules are the same.
Can I format text based on another cell’s value?
Yes. Use a formula that references another cell. For example, to highlight A2 if B2 contains “Yes”: select A2, use formula =$B$2="Yes" (absolute reference) or =B2="Yes" if you want it to adjust for each row.
How do I remove conditional formatting?
Select the range, go to Home > Conditional Formatting > Clear Rules > Clear Rules from Selected Cells. To remove all rules from the sheet, choose “Clear Rules from Entire Sheet”.
Related
- Maximum Number of Entries Has Been Reached? Explained
- Formatting a Cell in Excel: The Complete Guide
- Java String split() Method: How to Use It
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Flip Names in Excel in the Same Cell With a FormulaTo flip a name such as John Smith to Smith John in Excel for Microsoft 365, enter a…
- Excel Formula for Current Time: NOW, TIME, and UpdatesTo show the current date and time in Excel, enter =NOW(). To show only the time, use the…
- Excel Wildcard Text Search: Formulas and Examples GuideTo check whether text in A2 contains the search term in E2, use =ISNUMBER(SEARCH(E2,A2)). It returns TRUE when…
- Excel Formula for Fiscal Year: Step-by-Step GuideThe simplest Excel formula for determining a fiscal year is =YEAR(A2)+(MONTH(A2)>=FiscalStartMonth), where A2 contains the date and FiscalStartMonth…
- Excel Formula for Weekday: IF, WEEKDAY & MoreThe simplest Excel formula to check if a date is a weekday is =IF(WEEKDAY(A2,2)<6,"Weekday","Weekend"), where A2 contains the…
- Excel Count Dates Older Than Today: Formula and FixesTo count dates in Excel that are earlier than today, use =COUNTIFS(A2:A100,"
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.