Learn how to quickly highlight the full row according to a single cell's value in Excel. Tips and formula examples for numeric and text values.
The previous week we covered how to alter the background color of a cell depending on its value. In this article, you'll discover how to emphasize complete rows in Excel based on the value of one cell, along with some tips and formula examples that work with numeric and text cell values.
How to modify a row color based on a number in a single cell ------------------------------------------------------------Imagine you have a table listing your company's orders like this:
You might wish to shade the rows in varying colors depending on the value in the Qty. column to easily spot the most critical orders at a glance. This can be accomplished effortlessly using Excel Conditional Formatting.
Begin by selecting the cells whose background color you intend to change.
Generate a new formatting rule by clicking Conditional Formatting > New Rule… on the Home tab.
-
Within the "New Formatting Rule" dialog box that appears, opt for the option "Use a formula to determine which cells to format" and input the following formula in the "Format values where this formula is true" field to highlight orders with Qty. larger than 4:
=$C2>4
Naturally, you can utilize the less than (
=$C2
=$C2=4
Additionally, take note of the dollar sign $ preceding the cell's address - it is essential to maintain the column letter consistent when the formula gets replicated across the row. It is precisely this that achieves the effect of applying formatting to the entire row based on the value in a given cell.
-
Press the "Format…" button and navigate to the Fill tab to select the background color. If the default colors are insufficient, click the "More Colors…" button to pick a preferred color, then click OK twice.
You can also apply any other formatting options, such as font color or cell borders, on the other tabs of the Format Cells dialog.
The preview of your formatting rule will appear similar to this:
-
If this aligns with your preference and you're satisfied with the color, click OK to observe your new formatting in action. Now, if the value in the Qty. column exceeds 4, all rows in your Excel table will turn blue.
As you can see, altering the row's color based on a number in a single cell is quite straightforward in Excel. Subsequently, you will encounter more formula examples and a couple of tips for more intricate scenarios.
How to apply multiple rules with the priority you desire
In the prior example, you might prefer to shade rows with differing values in the Qty. column in distinct colors. For instance, you can add a rule to tint rows with a quantity of 10 or higher. In this scenario, employ this formula:
=$C2>9
Once your second formatting rule is established, arrange the rules' priority so both of your rules operate effectively.
On the Home tab, within the Styles group, click Conditional Formatting > Manage Rules… .
Choose "This worksheet" in the "Show formatting rules for" field. To control the rules that apply solely to your current selection, choose "Current Selection".
-
Select the formatting rule you wish to apply first and move it to the top of the list using the arrows. The outcome should resemble this:
Click the OK button and the corresponding rows will promptly adjust their background color based on the cell values you specified in both formulas.
How to modify a row color based on a text value in a cell
In our sample table, to simplify order tracking, you can shade rows based on the values in the Delivery column, ensuring:
- Rows with an order marked as "Due in X Days" turn orange;
- Items labeled "Delivered" have their entire row colored green;
- Orders flagged as "Past Due" shift to red.
Naturally, the row color will update if the order status changes.
Although the formula from our initial example could handle "Delivered" and "Past Due" (=$E2="Delivered"
and =$E2="Past Due"
), the task seems trickier for "Due in…" orders. As observed, different orders are due in 1, 3, 5, or more days, and the aforementioned formula won't work since it targets exact matches.
In this case, it's better to use the SEARCH function that works for partial matches as well:
=SEARCH("Due in", $E2)>0
In this formula, E2 is the address of the cell you want to base your formatting on, the dollar sign ($) locks the column coordinate, and >0 indicates that formatting will be applied if the specified text ("Due in" in our case) is found anywhere in the cell.
Create three such rules following the steps from the first example, and you'll end up with the following table as the result:
Highlight row if cell begins with specific text
Using >0 in the above formula implies that the row will be colored regardless of where the specified text is positioned in the key cell. For instance, the Delivery column (F) may contain the text "Urgent, Due in 6 Hours", and this row will still be colored.
To change the row color when the key cell begins with a particular value, use =1 in the formula, for example:
=SEARCH("Due in", $E2)=1
In this case, the row will only be highlighted if the specified text is found at the beginning of the cell.
For this conditional formatting rule to function correctly, ensure there are no leading spaces in the key column; otherwise, you might struggle to understand why the formula doesn't work. You can use this free tool to detect and eliminate leading and trailing spaces in your worksheets - Trim Spaces tool for Excel.
How to modify a cell's color based on a value in another cell
In reality, this is merely a variation of the row color-changing scenario. Instead of the entire table, you select a column or range where you want to highlight rows and use the formulas described earlier.
For instance, we could create three such rules to shade only the cells in the "Order number" column based on another cell's value (values in the Delivery column).
Highlight rows based on several conditions
If you wish to shade rows in the same color based on several values, rather than creating multiple formatting rules, you can use the OR or AND functions to establish several conditions.
For instance, we can color orders due in 1 and 3 days in a reddish hue, and those due in 5 and 7 days in yellow. The formulas are as follows:
=OR($F2="Due in 1 Days", $F2="Due in 3 Days")
=OR($F2="Due in 5 Days", $F2="Due in 7 Days")
And you can use the AND function, for instance, to change the background color
The above is the detailed content of Excel: Change the row color based on cell value. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

MicrosoftTeamsusesalotofmemoryprimarilybecauseitisbuiltonElectron,whichrunsmultipleChromium-basedprocessesfordifferentfeatureslikechat,videocalls,andbackgroundsyncing.1.Eachfunctionoperateslikeaseparatebrowsertab,increasingRAMusage.2.Videocallswithef

Quick Links Let Copilot Determine Which Table to Manipu

MicrosoftTeams’freeversionlimitsmeetingsto60minutes.1.Thisappliestomeetingswithexternalparticipantsorwithinanorganization.2.Thelimitdoesnotaffectinternalmeetingswhereallusersareunderthesameorganization.3.Workaroundsincludeendingandrestartingthemeetin

Grouping by month in Excel Pivot Table requires you to make sure that the date is formatted correctly, then insert the Pivot Table and add the date field, and finally right-click the group to select "Month" aggregation. If you encounter problems, check whether it is a standard date format and the data range are reasonable, and adjust the number format to correctly display the month.

Microsoft Teams is not complicated to use, you can get started by mastering the basic operations. To create a team, you can click the "Team" tab → "Join or Create Team" → "Create Team", fill in the information and invite members; when you receive an invitation, click the link to join. To create a new team, you can choose to be public or private. To exit the team, you can right-click to select "Leave Team". Daily communication can be initiated on the "Chat" tab, click the phone icon to make voice or video calls, and the meeting can be initiated through the "Conference" button on the chat interface. The channel is used for classified discussions, supports file upload, multi-person collaboration and version control. It is recommended to place important information in the channel file tab for reference.

Quick Links Check the File's AutoSave Status

The tutorial shows how to toggle light and dark mode in different Outlook applications, and how to keep a white reading pane in black theme. If you frequently work with your email late at night, Outlook dark mode can reduce eye strain and

To set up the repeating headers per page when Excel prints, use the "Top Title Row" feature. Specific steps: 1. Open the Excel file and click the "Page Layout" tab; 2. Click the "Print Title" button; 3. Select "Top Title Line" in the pop-up window and select the line to be repeated (such as line 1); 4. Click "OK" to complete the settings. Notes include: only visible effects when printing preview or actual printing, avoid selecting too many title lines to affect the display of the text, different worksheets need to be set separately, ExcelOnline does not support this function, requires local version, Mac version operation is similar, but the interface is slightly different.
