Google Sheets Conditional Formatting: Highlight Rows
In this article
Conditional formatting in Google Sheets allows you to automatically change the appearance of cells based on their content, such as highlighting an entire row if a specific cell contains certain text. This visual cue makes it easier to spot critical data, like overdue tasks or high-priority items, without manually scanning every line. To achieve this, you will use a custom formula within the conditional formatting rules menu, ensuring that the highlight applies to the whole row rather than just the single cell containing the text.
What You'll Need
- A Google Sheets document with your data organized in rows and columns.
- Access to edit permissions for the spreadsheet (view-only users cannot apply formatting).
- The specific text string or keyword you want to trigger the highlight (e.g., "Completed", "Urgent").
- An understanding of which column contains the target text (e.g., Column B).
Step-by-Step
- Select the range: Click and drag to select all the rows and columns you want to be affected by the rule. For example, if your data is in A1:D100, select A1:D100. Do not select just the header row unless you want headers highlighted too; usually, you start from the first data row.
- Open Conditional Formatting: In the top menu bar, click on Format, then hover over Conditional formatting. Click on Add another rule if you already have rules, or just Conditional formatting to open the side panel.
- Set the condition type: In the right-hand sidebar under "Apply to range," ensure your selected range is correct. Under "Format rules," click the dropdown menu and select Custom formula is.
- Enter the formula: In the "Choose a color to apply" box below, enter the formula that checks for the text. The syntax depends on whether you want an exact match or partial match. For a partial match (contains text), use:
=SEARCH("YourText", $B2). Replace "YourText" with the word you are looking for and "$B2" with the first cell of the column containing your target text. Note the dollar sign before the column letter ($B) but not the row number (2). This locks the column reference so the rule applies across the entire row. - Choose a fill color: Select the background color you want applied to the highlighted rows. You can also choose font color or bold styling if desired.
- Preview and Apply: Check the preview pane at the bottom of the sidebar to see how your data looks with the new rule. If it looks correct, click Done to apply the formatting.
Common Mistakes
One frequent error is forgetting the dollar sign ($) before the column letter in the formula. If you write =SEARCH("Text", B2) instead of =SEARCH("Text", $B2), the rule will shift relative to each cell. This means cell C3 might check column D, and cell D4 might check column E, resulting in inconsistent highlighting across the row. Always lock the column reference when applying a rule to multiple columns.
Another common issue is selecting the wrong starting row in the formula. If your data starts in row 2, your formula must reference row 2 (e.g., $B2). If you reference $B1 while your selection starts at A2, the logic may misalign, causing the wrong rows to highlight or none at all.
Users often forget to include the entire row in the "Apply to range" section. If you only select column B, only that column will highlight, even if the formula is correct. Ensure your range covers all columns you want to visually emphasize.
Tips
Use case-insensitive functions like SEARCH instead of FIND if you want to catch variations in capitalization. SEARCH returns a position number if found, which evaluates to TRUE in conditional formatting, whereas FIND is case-sensitive.
You can combine multiple conditions using AND or OR functions. For example, to highlight a row if Column B contains "Urgent" AND Column C is empty, use: =AND(SEARCH("Urgent", $B2), ISBLANK($C2)).
To make maintenance easier, consider using named ranges for your data. Instead of hardcoding A1:D100, define a named range called "TaskList." While conditional formatting still requires standard references in formulas, keeping your data structured helps prevent errors when adding new rows.
If you need to highlight based on numeric values rather than text, use simple comparison operators like =$C2>100 instead of search functions.
Troubleshooting
If nothing highlights, double-check the spelling of the text in your formula against the actual cell contents. Extra spaces or different capitalizations can cause mismatches. Use TRIM() in your formula if necessary, though SEARCH generally handles minor whitespace issues well.
Verify that your "Apply to range" does not overlap with other conditional formatting rules that have higher priority. Rules are evaluated from top to bottom in the sidebar. If a previous rule sets a format for the same cells, it might override your new rule. You can reorder rules by dragging them up or down in the sidebar.
Ensure your sheet is not protected. If the range you are trying to format is locked for editing, you may not be able to add or modify conditional formatting rules. Unprotect the sheet via Data > Protect sheets and ranges if needed.
Check for circular references or errors in the cells being referenced. If the cell containing the text has an error value (#N/A, #VALUE!), the SEARCH function might fail or behave unexpectedly. Wrap your formula in IFERROR if necessary, e.g., =IFERROR(SEARCH("Text", $B2), FALSE).