Skip to content

Excel Conditional Formatting

    Conditional formatting is used by every Excel user, whether a beginner or an expert. Specifically, conditional formatting allows us to change the layout of certain parts of a worksheet based on specific dynamic conditions, making it easier to present the worksheet to others and improving its readability.

    In this article, we’ll explore some of the most common methods for using conditional formatting through concrete examples. Our starting file will contain a list of various sales representatives and their sales figures, values that we want to sort and display differently using conditional formatting.

    Sales agents table with values highlighted using conditional formatting

    Excel Conditional Formatting: Cell Highlighting Rules Section

    The first section of conditional formatting includes several options to help you best display the values on the worksheet:

    • Greater Than / Less Than: We define a threshold, and the formatting highlights all values above or below the defined threshold
    • Between: We define a minimum and a maximum. Any value between these two will be highlighted
    • Equal To: This option works with both text and numbers, highlighting them if they match the value we enter
    • Text that Contains: For text-only cells; if the cell contains the text we enter, it will be highlighted
    • A Date Occurring: In this case, we need to be careful because Excel, by default, considers Sunday to be the start of the week. Any value matching “Yesterday,” “Next Week,” etc. (depending on which option we choose) will be highlighted
    • Duplicate Values: Select a range; if there are duplicate values, they will be formatted

    How to Highlight Numbers Greater Than a Certain Value with Conditional Formatting

    Let’s say, for example, that we want to highlight cells with values greater than a certain number (1,000). Click Home > Conditional Formatting > Highlight Cells Rules > Greater Than:

    Highlight Cells Rules with Greater Than to highlight values above 1,000

    By default, Excel will try to display these values with a light red fill and dark red text, but you can change the format by clicking on Custom Format:

    Greater Than dialog with the default light red fill

    Let’s change the fill color to green:

    Format Cells dialog Fill tab used to choose green

    Let’s also change the font color to white so the values are easier to see:

    Format Cells dialog Font tab used to choose white text

    We’re done! Now we can see the numbers greater than 1,000 highlighted in green with white text, just as we specified.

    SALES values selected to apply conditional formatting

    How to Highlight Cells Using Values from Another Cell via Conditional Formatting

    As we can see, the display could be improved since it’s not entirely clear how to associate the names with the individual values. If we want to modify the formatting to include the names as well, we can do so by selecting the range from A2 to A11 and then clicking Home > Conditional Formatting > Highlight Cells Rules > More Rules:

    Conditional Formatting menu with Highlight Cells Rules

    In this case, we need to use a formula to achieve the same result. We’ll often need to do this to replicate conditional formatting functionality on text values, this time it’s simple, since all we need to do is enter =B2>1000. It’s not necessary to include the initial IF because Excel formats the values for which the formula returns true, but we’ll need to remember to enter B2 without the dollar sign to allow Excel to drag the formulas down (which will become B3>1000, B4>1000, and so on).

    Conditional Formatting Rules Manager with the formula rule =$B2>1000 applied to A2:B11

    In the final result, we can see that the text now has the same formatting as the numerical values, ensuring excellent readability.

    Agents with sales above 1000 highlighted on the whole row

    How to Color Alternating Rows Using Conditional Formatting

    You may want to display rows differently by alternating their fill color. The recommendation is not to do this by filling individual rows, because any change would ruin the formatting. With conditional formatting, however, we can achieve an excellent result using formulas.

    The starting point is always the same worksheet, but in this case, click Home > Conditional Formatting > New Rule:

    Conditional Formatting Rules Manager with the =MOD(ROW(),2) rule for alternating rows

    The formula we enter is a combination of MOD and ROW:

    =MOD(ROW(),2)

    The logic behind the formula is to divide ROW (1 for A1, 2 for A2) by two. If this division results in a remainder, then the condition is true, if there is no remainder, then the rule does not apply. The same logic would apply for every 3rd or every 5th row; you’d simply need to change the divisor from 2 to 3 or 5.

    Let’s also modify the formatting by adding a yellow fill:

    Fill color chosen for the alternating rows

    Here is the final result with alternating rows.

    Alternating rows formatted with a MOD and ROW rule

    How to Format Cells in Excel Based on Text

    Let’s use the previous list as an example again. In this case, we want to see which names contain the vowel “O.” Click on Home > Conditional Formatting > Highlight Cells Rules > Text that Contains, enter the value “O,” and set the fill color to green with dark green text:

    New Formatting Rule to format only cells that contain a text

    In the final result, we see that only the cells containing an "O" have been highlighted. In this case, the highlighting is not case-sensitive (both "O" and "o" are valid conditions for highlighting).

    Cells containing the letter O highlighted

    How to Highlight Duplicates with Conditional Formatting

    In some cases, we may want to highlight duplicates, particularly to avoid errors in subsequent calculations. So let’s add another row of values, where we have Luka Doncic and 650 as the sales value.

    Table with a duplicate agent added

    By clicking Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values, we already see the duplicate, since row 9 with Wes Unseld also has a value of 650.

    Duplicate values highlighted with conditional formatting

    As in the previous case, however, we also want to highlight the names differently, not just the numbers. So, click on Home > Conditional Formatting > New Rule:

    Rule highlighting the names of the duplicate rows

    The formula in this case uses the function COUNTIF:

    =COUNTIF($B$2:$B$12,B2)>1

    Note that the range is locked, while cell B2 will move downward to adjust based on the corresponding sales value. Let’s also modify the formatting by first setting the fill color to black :

    Format Cells Fill tab for the duplicate rule

    Next, let’s set the font color to white:

    Format Cells Font tab with white text for the duplicates

    The final result will be very helpful in our work, allowing us to distinguish both the name and the number to verify which agents made the same sales.

    Duplicate values highlighted in the DUPLICATES sheet

    Excel Conditional Formatting: Top/Bottom Rules Section

    In this section, we have the following options:

    • Top 10 Items / Bottom 10 Items: We can quickly view, for example, the top 3 or bottom 8 values in a range
    • Top 10% / Bottom 10%: See above, but using percentages
    • Above Average / Below Average: Highlight values that are lower or higher than the range’s average

    Excel Conditional Formatting: Highlight the Top 5 Values

    Conditional formatting is also used to display the largest values within a certain range. In this case, we want to highlight the top 5 values in our range, so click Home > Conditional Formatting > Top/Bottom Rules:

    Top 10 Items rule set to the top 5 values

    By selecting 5 and modifying the formatting (following the same instructions as before, only the color changes), we can easily display the 5 values we’re interested in.

    Top 5 sales highlighted in the range

    As in other cases, it’s best to also display the names associated with the values to better present our work. So, let’s select the values in Column A and click Home > Conditional Formatting > New Rule:

    Formula rule with LARGE highlighting the names of the top 5

    The formula uses the function LARGE to allow us to display the values from first to fifth:

    =B2>=LARGE($B$2:$B$11,5)

    The formula instructs Excel to highlight cells only if the corresponding value is at least the fifth largest (the last element of the LARGE function), making it dynamic since B2 is not locked with a dollar sign.

    The final result ensures that both parts of the worksheet display the same information.

    Names and values of the top 5 agents highlighted

    Excel Conditional Formatting: What Are Data Bars?

    Another feature you can use to improve the visualization of a single worksheet is definitely data bars. In this case, it almost looks like you have a chart inside a cell, created by clicking Home > Conditional Formatting > Data Bars and selecting your preferred color:

    Data bars showing the sales inside the cells

    The formatting isn’t always ideal, but you can still tell at a glance that Billy Cunningham and Oscar Robertson definitely sold more than Charles Barkley or Scottie Pippen.

    Data bars comparing the sales of the agents

    Let’s try modifying the formatting rule, just click Home > Conditional Formatting > Manage Rules:

    Conditional Formatting Rules Manager to edit the data bars

    For example, let’s say we want to display only the bar without showing the numbers and add a black border. Just check “Show only the bar” and change the border color:

    Conditional Formatting Rules Manager showing the Data Bar rule on the sales

    The final result could already be inserted into a slide as a chart and can be useful for making more strategic analyses rather than focusing on individual numbers, as we see in the next image.

    Data bars without numbers ready to use as a chart

    Another trick, again, to hide the numbers, is to select the range and enter three semicolons in a row (;;;) as the Custom Format. In this case as well, the values aren’t deleted from the data but simply aren’t displayed.

    Custom number format ;;; hiding the values

    How to Implement Color Scales in Conditional Formatting

    If data bars don’t quite meet our needs, we can also use color scales to achieve the same result. These provide a quick way to visualize values without getting too specific; you can start by clicking Home > Conditional Formatting > Color Scales > More Rules. We recommend switching to “More Rules” because it offers greater flexibility and fewer “bold” colors, which can sometimes be a bit distracting in the layout.

    Conditional Formatting menu with Color Scales

    Let’s select the conditions: we want the midpoint to be the 50th percentile and the colors to be lighter than the standard ones.

    Conditional Formatting Rules Manager showing the 3-color scale on the sales

    Let’s modify the font by setting it to white and bold, so we end up with a result similar to the one in the image below.

    Color scale applied to the sales values

    Of course, in this case as well, we could use the formatting trick with ;;; to hide the values and display only the colors.

    Excel Conditional Formatting: Icon Sets

    Icon sets are often used because they offer a good compromise between color scales (which can be very intrusive) and data bars, which remain one of the best ways to get a general idea without cluttering the sheet with confusing information. In this case, click Home > Conditional Formatting > Icon Sets> More Rules, where you’ll select the green icon if the value is greater than or equal to 67%, yellow if between 33% and 67%, and red for all others:

    Conditional Formatting Rules Manager showing the icon set rule on the sales

    As we can see, even in this case, we can easily view the values and distinguish between them. If we don’t want to see the numerical values, we can simply click “Show icon only.” The only thing to keep in mind is that to display the icons correctly (otherwise they’ll appear pixelated), we need to make sure the font size in File > Options > General is at least the same as the current cell’s font size (in this case, 16).

    Icon set applied to the sales values

    Conclusion

    Conditional formatting changes the look of cells based on rules: highlighting values above a threshold, comparing cells, coloring alternate rows, finding text or duplicates, and adding icon sets. Since the rules are dynamic, the formatting updates as soon as the data changes.

    Leave a Reply

    Your email address will not be published. Required fields are marked *