Excel Conditional Formatting tutorial with examples

The tutorial explains all main features of Excel conditional formatting with examples. You will learn how to do conditional formatting in any version of Excel, efficiently use preset rules or create new ones, edit, copy and clear formatting.

Excel conditional formatting is a really powerful feature when it comes to applying different formats to data that meets certain conditions. It can help you highlight the most important information in your spreadsheets and spot variances of cell values with a quick glance.

Many users, especially beginners, find it intricate and obscure. If you feel intimidated and uncomfortable with this feature, please don't! In fact, conditional formatting in Excel is very straightforward and easy to use, and you will make sure of this in just 5 minutes when you have finished reading this tutorial :)

What is conditional formatting in Excel?

Excel Conditional Formatting is used to apply certain formatting to data that meets one or more conditions. Just like usual cell formatting, it lets you highlight and differentiate your data in various ways by changing cells' fill color, font color, border styles, etc. The difference is that it is more flexible and dynamic - when the data changes, conditional formats get updated automatically to reflect the changes.

Conditional formatting can be applied to individual cells or entire rows based on the value of the formatted cell itself or another cell. To conditionally format your data, you can utilize preset rules such as Color Scales, Data Bars and Icon Sets or create custom rules where you define when and how the selected cells should be highlighted. Excel conditional formatting

Where is conditional formatting in Excel?

In all versions of Excel 2010 through Excel 365, conditional formatting resides in the same place: Home tab > Styles group > Conditional formatting. Conditional formatting on the Excel ribbon

Now that you know where to find conditional formatting in Excel, let's move on and see how you can leverage it in your daily work to make more sense of the project you are currently working on.

For our examples, we will use Excel 365, which seems to be the most popular version these days. However, the options are essentially the same in all Excels, so you won't have any problems with following no matter what version is installed on your computer.

How to use conditional formatting in Excel

To truly leverage the capabilities of conditional format, you need to learn how to utilize various rule types. The good news is that whatever rule you are going to apply, it defines the two key things:

  • What cells are covered by the rule.
  • What condition should be met.

So, here's how you use Excel conditional formatting:

  1. In your spreadsheet, select the cells you want to format.
  2. On the Home tab, in the Styles group, click Conditional Formatting.
  3. From a set of inbuilt rules, choose the one that suits your purpose.

    As an example, we are going to highlight values less than 0, so we click Highlight Cells Rules > Less Than… Using preset Highlight Cells Rules
  4. In the dialog window that appears, enter the value in the box on the left and choose the desired format from the drop-down list on the right (default is Light Red Fill with Dark Red Text).

    When done, Excel will show you a preview of formatted data. If you are happy with the preview, click OK. Preview of the conditionally formatted data

In a similar manner, you can use any other rule type that is more appropriate for your data, such as:

  • Greater than or equal to
  • Between two values
  • Text that contains specific words or characters
  • Date occurring in a certain range
  • Duplicate values
  • Top/bottom N numbers

How to use a preset rule with custom formatting

If none of the predefined formats suits you, you can choose any other colors for cells' background, font or borders. Here's how:

  1. In the preset rule dialog box, from the drop-down list on the right, pick Custom Format… Setting up custom formatting
  2. In the Format Cells dialog window, switch between the Font, Border and Fill tabs to choose the desired font style, border style and background color, respectively. As you do this, you will immediately see a preview of the selected format. When done, click OK. Choosing the fill color
  3. Click OK one more time to close the previous dialog window and apply the custom formatting of your choice. Custom format is applied to the selected cells.

Tips:

  • If you want more colors than the standard palette provides, click the More Colors… button on the Fill or Font tab.
  • If you wish to apply a gradient background color, click the Fill Effects button on the Fill tab and choose the desired options.

How to create a new conditional formatting rule

If none of the preset rules meets your needs, you can create a new one from scratch. To get it done, follow these steps:

  1. Select the cells to be formatted and click Conditional Formatting > New Rule. Create a new conditional formatting rule in Excel.
  2. In the New Formatting Rule dialog box that opens, select the rule type.

    For example, to format cells with percent change less than 5% in either direction, we choose Format only cells that contain, and then configure the rule like shown in the screenshot below: Choose the conditional formatting rule type.
  3. Click the Format… button, and then choose the Fill or/and Font color you want.
  4. Click OK twice to close both dialog windows and your conditional formatting is done! New conditional formatting rule is created and applied to the selected cells.

Excel conditional formatting based on another cell

In the previous examples, we highlighted cells based on "hardcoded" values. However, in some cases it makes more sense to base your condition on a value in another cell. The advantage of this approach is that irrespective of how the cell value changes in future, your formatting will adjust automatically to respond to the change.

As an example, let's highlight prices in column B that are greater than the threshold price in cell D2. To accomplish this, the steps are:

  1. Click Conditional formatting> Highlight Cells Rules > Greater Than…
  2. In the dialog box that pops up, place the cursor in the text box on the left (or click the Collapse Dialog icon), and select cell D2.
  3. When done, click OK.

As a result, all the prices higher than the value in D2 will get highlighted with the selected color: Create a conditional formatting rule based on another cell value.

That is the simplest case of conditional formatting based on another cell. More complex scenarios may require the use of formulas. And you can find several examples of such formulas along with the step-by-step instructions here:

Apply multiple conditional formatting rules to same cells

When using conditional formats in Excel, you are not limited to only one rule per cell. You can apply as many rules as your business logic requires.

For example, you can create 3 rules to highlight prices higher than $105 in red, higher than $100 in orange, and higher than $99 in yellow. For the rules to work correctly, you need to arrange them in the right order. If the "greater than 99" rule is placed first, then only the yellow formatting will be applied because the other two rules won't have a chance to be triggered - obviously, any number that is higher than 100 or 105 is also higher than 99 :)

To re-arrange the rules, this is what you need to do:

  1. Select any cell in your dataset covered by the rules.
  2. Open the Rules Manager by clicking Conditional Formatting > Manage Rules…
  3. Click the rule that needs to be applied first, and then use the upward arrow to move it to top. Do the same for the second-in-priority rule.
  4. Select the Stop If True check box next to all but the last rule because you do not want the subsequent rules to be applied when the prior condition is met.
Arrange the conditional formatting rules in the right order

What is Stop if True in Excel conditional formatting?

The Stop If True option in conditional formatting prevents Excel from processing other rules when a condition in the current rule is met. In other words, if two or more rules are set for the same cell and Stop if True is enabled for the first rule, the subsequent rules are disregarded after the first rule is activated.

In the example above, we have already used this option to ignore subsequent rules when the first-in-priority rule applies. That usage is quite evident. And here are another couple of examples where the use of the Stop If True function is not so obvious but extremely helpful:

How to edit Excel conditional formatting rules

To make some changes to an existing rule, proceed in this way:

  1. Select any cell to which the rule applies and click Conditional Formatting > Manage Rules…
  2. In the Rules Manager dialog box, click the rule you want to modify, and then click the Edit Rule… button. Edit a conditional formatting rule in Excel.
  3. In the Edit Formatting Rule dialog window, make the required changes and click OK to save the edits.

    That dialog window looks very similar to the New Formatting Rule dialog box used for creating a new rule, so you won't have any difficulties with it.

Tip. If you don't see the rule you want to edit, then select This Worksheet from the Show formatting rules for drop-down list at the top of the Rules Manager dialog box. This will display the list of all the rules in your worksheet.

How to copy Excel conditional formatting

To apply a conditional format you've created earlier to other data, you won't need to re-create a similar rule from scratch. Simply use Format Painter to copy the existing conditional formatting rule(s) to another data set. Here's how:

  1. Click any cell with the formatting you want to copy.
  2. Click Home > Format Painter. This will change the mouse pointer to a paintbrush.

    Tip. To copy the formatting to multiple non-contiguous cells or ranges, double-click Format Painter.

  3. To paste the copied formatting, click on the first cell and drag the paintbrush down to the last cell in the range you want to format. Copy conditional formatting to another range of cells.
  4. When done, press Esc to stop using the paintbrush.
  5. Select any cell in your new dataset, open the Rules Manager and check the copied rule(s).

Note. If the copied conditional formatting uses a formula, you may need to adjust cell references in the formula after copying the rule.

How to delete conditional formatting rules

I've saved the easiest part for last :) To delete a rule, you can either:

  • Open the Conditional Formatting Rules Manager, select the rule and click the Delete Rule button. Delete a conditional formatting rule.
  • Select the range of cells, click Conditional Formatting > Clear Rules and choose the option that fits your needs. Clear conditional formatting rules in Excel.

This is how you do conditional formatting in Excel. Hopefully, these very simple rules we created were helpful to get a grasp of the basics. Below, you can find a few more tutorials that can help you understand the inner mechanics and expand conditional formatting in your spreadsheets far beyond its traditional uses.

You may also be interested in

Latest comments

  1. i have the same data from 2 companies with different orders placed
    I would like the different data highlighted so i can filter by the color to see the items
    column 1 column 2
    5009 0
    5009 0
    5010 0
    5010 1
    i would like to see the quantity 0 and 1 highlighted for items 5010
    hope this makes sense, any items that are equal I don't need

  2. Hi, I need to find if data in column B, row 6 is in range with the master data sheet and sgould be color flagged if any info is incorrect in that row. Thank you.

  3. Hi Can i have the formula, If A1 is highlighted put "remarks"? thanks

  4. Hi, I'm wondering,
    Once I do a conditionnal formating on a row, for example, in my expire dates collum, I set it up so that it highlights all date that are before January 1st 2025.
    How can I now set something up so that I can hide all rows that have those dates highlighted in my expire dates collum?

    Thank you :)

  5. hey i have a question
    so, i want the value in a cell to a highlight a row
    lets say for example the value in a cell is 5 meaning, it should highlight 5 rows
    same with the columns, if the cell for the column has a value of 5, it should highlight 5 columns
    starting from cell A5 then it should highlight to cell A10
    basically, making a highlighted 5x5 matrix
    can you help me with that?

  6. I have an array of numbers by year (column) D5:H10, the year is in row 4. I would like to highlight a entire column if the year for that column = the value in a cell that the user enters at the top - cell C2. It seems simple enough, but I'm having trouble.

    I tried D$4=$C$2 applied to D4:D10

  7. Sir, at present I am facing these two problems. Please help me.

    1) I want to know one thing that when we are writing the formulas in the cell then those formulas are visible or going in the formula bar. I want to write that formula or formulas by VBA to solve the problem. How is it possible? If you give a detailed guide, it will be very helpful. For example, I am doing Date of Retirement calculation with EOMONTH or I am writing a specific formula in a cell to calculate Present Age. I want to run these formulas with VBA. How to do? That means, I will write date of birth in one cell and present age in another cell and Retirement Date will be written in another cell simultaneously/automatically.

    2) In those cells that cannot be duplicate entries, how can it be solved by conditional formatting? Means, I wrote the ID code in a cell, in the next case when entering that ID, a massage will show that this ID has been entered. It would be very helpful to know in detail how it can be solved.

  8. I'm pretty sure it's not possible, but maybe you guys know a way around; Is there any way to do partial formatting of a cell, that's the result of a formula?

    I have a cell that's the output of a formula, which is a text string, and I want to underline the first word/first 10 characters of that string.

  9. Is there a way to highlight all cells that are not formula (ie. hardcoded) to show where formulas in a range have been written over?

  10. Hello, I'm trying to determine how I can conditionally format a range of months based off of the Effective and expiration month dates, as well as the Start month.

    On the first example, the Start Month is Jan, that would be the first month cell to highlight, followed by the duration of months (differenc between Jan 2023 and March 2024 (14 months).

    In the next example, Start month is May, followed by a duration of 16 months ending in Sept (aligned with the Sept expiration date).

    Effective date will always be a prior date to the Expiration Date; duration can be anywhere from 6 months to 29 months; Start month will either be same month as effective date or the following month.

    Appreciate you taking the time to review!

    EffectiveDate ExpirationDate StartMonth Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr May Jun Jul
    1/1/2023 3/1/2024 Jan (JAN through March cells would be highlighted)
    4/1/2023 7/15/2024 May (MAY through July cells would be highlighted)

  11. Hello Sir!

    I am trying to highlight the whole row based on the first word I insert, for example:

    Region 1 = red, Region 2 = blue;

    So, when I type region 1, the column and its row will become red.

    Do you have a formula that I could use to do this? or do you have the guideline to do this in conditional formatting rules manager?

  12. Hello! I am trying to highlight cells based on if another cell has a date entered in it (cell in column "I" will need to change color once the corresponding cells in columns L, M, and N (each need to change individually). I do this to have an easy visual que that a sub-task has been completed. Cells in columns L, M, and N will be given dates once reports are issued/tasks completed - cells in L will get dates first, then M, and then N. Each row is a different item, and once the cells from L, M, and N are given dates, I need that row's "I" cell to change color. I was doing it by the NOT ISBLANK function, but then it would multiply/separate out when you open up rules, so adding a new one was difficult. I started out with 3 rules, and then they altered themselves and ended up showing up as twenty some, or more, different rules.

    So I guess two questions - do you have a formula that I could use to do this? And how do you keep rules from multiplying/modifying themselves?

    Thanks!

  13. Hey!

    So, I am trying to set up a conditional formatting function to highlight cells greater than 130 in each row. However, once the first cell to reach 130 in the row is highlighted, I do not want the following numbers to be highlighted (since the numbers just increase).

    I tried using the in-between function but that would give me a range greater than 30 for some rows and simply is not working for the spread I am using.

    Is there a specific function for this in conditional formatting?

    1. Hi! If I understand you correctly, to select only the first value greater than 130, select row 2 and create a conditional formatting rule:

      =COUNTIF($A$2:A2,">130")=1

      You can learn more about COUNTIF in this article: Excel COUNTIF function examples. Hope this is what you need.

  14. i want the conditional formatting i created for a cell to be copied down to the next. but i want the continuation of the references as well. example the first cell's reference is $G$1, the next cell should be $G$2 and so on. i can do this one by one. but is there a faster way to do it. or a shortcut or maybe a command for multiple cells like dragging down. because when i drag down. the reference cell is the same.

  15. Can you use conditional formatting to change background colour depending on the case of individual letter (CHAR) been LOWER or UPPER? i.e. 'c' or 'C'

    1. Hi!
      For uppercase letters, this formula will return TRUE

      =AND(CODE(LEFT(A2,1))<91,CODE(LEFT(A2,1))>64)

      I hope it’ll be helpful. If something is still unclear, please feel free to ask.

      1. I prefer this:
        =EXACT(LEFT(A2,1),UPPER(LEFT(A2,1)))

  16. I need to highlight a cell that doesn’t contain 48

  17. What are the different number formats?How will you change the format of the number?write the steps

  18. I want to set the conditions of a cell to:
    today's date - 180 days turn red
    today's date - 135 days turn orange
    today's date - 90 days turn yellow
    today's date - 75 days turns green

    Can anyone help?

    1. Josh:
      You've asked to apply four different conditional formats based on four different conditions, so you'll need four rules all applied to the same range of cells.
      Select the range of cells to which you want to apply the rules.
      Select Conditional Formatting, select Highlight Cell Rules, then More Rules, then select Use Formula to determine which cells to format.
      Where the range is H48:H51, in the field that is displayed enter this formula:
      =AND(H48>TODAY(),H48=(TODAY()+75))
      Notice that the formula references the top left cell in the range H48:H51. Your range and top left cell is probably different, but this formula must reference the top left cell in the range.
      Notice that this formula will apply the formatting to the date that is 75 days from today.
      The H48>TODAY() ensures the date in H48 is not in the past.
      You asked for TODAY()+ 180, etc. so the formula includes H48=(TODAY()+75), etc. So it is only formatting the cells that are equal to 180 days (or whatever number of days)from today. Not greater than the number of days from today. This allows you to put different formatting to each rule and specific future date.
      Select format, then choose the fill color then OK and then apply and OK your way back to the dialogue window that displays the rules.
      In that window you'll want to click Add New Rule so that you can enter a new rule which will have the same formula except that you'll change the "+" number to the different number of days and different formatting for each different rule.
      Follow this same procedure until you have all four rules and their respective formatting the way you want them.

  19. Hello,
    I am trying to create a training document. The document will contain several employees, each having a date they were certified, and then a date that they will be due to re-certify. I am trying to figure out the formulas that I would need to input in order to change the row either red=overdue, yellow=due within 90 days, and green=91days>. The formula that seems to be closest to what I need is Rule1=datedif($A2,Today(),"d")>=1:89,Rule2=datedif($A2,today(),"d")>=90:275, and Rule3=datedif($A2,today(),"d")>=276 but for some reason the rules are keeping all three colors from showing. could you please point me in the right direction and thank you for your time.

    1. Hello, Ian,

      Please try the following formulas:

      Rule1=AND(DATEDIF($A2,TODAY(),"d")>=1,DATEDIF($A2,TODAY(),"d")<=89)
      Rule2=AND(DATEDIF($A2,TODAY(),"d")>=90,DATEDIF($A2,TODAY(),"d")<=275)
      Rule3=DATEDIF($A2,TODAY(),"d")>=276

      Hope it will help you.

  20. Hello Dear Experts..

    I have a table in which I already inserted formula & conditional formatting to get the result.

    Example:- In column O3 I have mentioned Expiry Dates & in column P3 I have mentioned =O3-TODAY() & inserted conditional formatting to know remaining days to get expired with Less than value using colour format. (Like, colour to be change as yellow if days remain less than 60 & Red if days remain less than 30) it is working.

    But What I want is if the expiry date has not been mention in column O3 then Column P3 should be left blank without any text.

    Awaiting for your response

    1. Hello,
      you can add IF function to your formula in P3:
      =IF(ISBLANK(O3),"",O3-TODAY())

      It will remain empty if there's nothing in O3, otherwise calculate the date.
      Please read this article to learn why and when IF can be used.
      Hope this is what you need.

      1. Yes it's working, Thank you very much

Post a comment



Thanks for your comment! Please note that all comments are pre-moderated, and off-topic ones may be deleted.
For faster help, please keep your question clear and concise. While we can't guarantee a reply to every question, we'll do our best to respond :)