Comments on: Excel conditional formatting formulas based on another cell

This tutorial explains how to use Excel formulas to format cells and entire rows based on the values you specify or based on another cell's value, and provides a handful of formula examples. Continue reading

Comments page 49. Total comments: 1726

  1. In one of my Columns I need to ensure that only 10 numbers are input. I would like the cell to turn yellow if any more or less characters are input. This will help to alleviate me having to track people down for corrections if they know immediately that they have input this number combination with to many or to few characters.

    1. Hello Geoff,

      I think you can create a rule with this formula
      =OR(len($G2)<10,len($G2)>10)

      Where G2 is the first cell in your column, not including headers.

  2. Is there a way to move a whole row to a new sheet based on the contents of one cell? I have a column titled "loan status" and it is either marked with a "C" (closed) or "O" (open). I would like all the closed loans to be moved to Sheet2 once I change the "loan status" to a "C". Thanks.

  3. hi
    I hope you can help with what must be very simple, but I can't get to work and no one else seems to have asked the question anywhere(perhaps because it is so simple LOL)
    I am keeping a record of electricity consumption by month. If for example the figure in B1(Jan 2014)is less than the figure in A1 (Jan 2013) I can conditionally format B1 to go green, but I can't for the life of me get B1 to remain clear if there is no figure in it. I'm guessing that a blank cell is less than any figure in A1? Is there a way to do it?
    Many thanks
    Steve

    1. Hi Steve,

      You are right, the solution is simple, though not obvious at first sight : ) You can achieve the desired result in 2 ways:

      1. Use the following formula for column B:
      =AND($B1<>"",$B1<$A1) The expression $B1<>"" checks whether a cell is not empty, and the AND formula applies the rule only if both conditions are met. 2. In addition to your current rule, create one more rule of the "Format only cells that contain" type > Cell value > Blanks for column B. Alternatively, you can create a rule based on this formula =$B1="", which also applies to blank cells only. Do not set any format for this rule. Finally, make sure this rule is the first in the list, and select the option "Stop if true" next to it.

      1. Brilliant! thank you; option 1 worked perfectly. Thank you so much.
        Steve

  4. Hello-

    So I am using Excel 2010 to keep a list of my exchange servers and all of the DBs at my company. I get a report mailed each morning and I take the values from those reports and import them into excel. From that data I create a bar graph using conditional formatting, but for some reasons the rules will not affect TWO CELLS. Only two. I have the rules setup to affect a range of cells from H6-H37. H10, and H20 simply do not respond to the rules I have configured. I have tried everything...re-writing the rules, I even specifically set the range as those cells individually and the rule still wouldn't affect them. Any ideas?

    Thanks in advance for the help.

    1. Hello,

      Most likely the problem is with the format of those 2 cells. You can try to copy the formal of some other cell where the rules are applied correctly using Excel's Format Painter. Did it help?

      Also you can check the list of rules in the Manage Rules dialog to make sure there are no other rules set for those 2 cells that override your new rules.

    2. Where is this pulling my picture from? That is creepy...

      1. Hello,

        The picture is automatically pulled from gravatar.com (Globally Recognized Avatar).

  5. Thank you. It's for a fantasy football draft, so the 3 data columns are Player Name, Position, and Team.

    I want to base the formatting on Position. So, if Position = QB it shades all 3 cells yellow. If Position = RB it shades them green... and so on.

    1. Thanks for the details, now the task is crystal clear : ) You can achieve the desired result in this way:

      - Select all the rows with data in those 3 columns, not including the column headers.
      - Create conditional formatting rules with the below formulas, assuming that column B is the "Position" column and row 2 is the first row with data:

      Yellow: =$B2="QB"
      Green: =$B2="RB"

  6. Hi,

    I'm trying to format 3 columns of data. Each row of these columns needs to be formatted based on 1 cell in that row. I am trying to format each row given 5 variables for that 1 cell. Is there a way I can do this?

    Thank you.

    1. Hi RW,

      I believe this is possible. However, to be able to suggest a formula, I need to know a bit more about your data. If you can provide an example of what exactly values you have in each of the 3 columns and what condition you want to base the formatting on, I think I will be able to help better.

  7. Hi.. I have conditionally formatted a row of data to highlight the highest cost and lowest cost for a product (each cost in a different column - b,c,d,e).
    How do I copy this format down to 1457 individual rows, without having to paste the format to each row individually?

    1. Hi Jocelyn,

      In conditional formatting rules, cell references are relative to the top-left most cell in the applied range.

      So, simply select all 1457 rows, and create 2 rules with the below formulas (assuming that B2 is the top left-cell in the applied range):
      =MAX($B2:$E2)=B2
      =MIN($B2:$E2)=B2

  8. Hello I am working on a retirement planning spreadsheet. I have keyed in a started working age, and a retirement age of 67. I need help in creating a formula that stops the series at age 67. For example, If I key in age 26, in my table, my series goes to age 71 bc I orginally formatted the table to have a basic start age of 22. I would like to be able to create formula that stops the series at age 67 regardless of the age you start working.

    1. Hi James,

      Try nesting your current formula inside the IF function in this way:
      =IF(A2<=67, YOURFORMULA, "")

      Where A is the collumn with the current age, e.g. 22. Then А46 will have "68" and at this point the formula stops the series.

      If the above approach does not work, please send us your sample workbook with the existing formula at support@ablebits.com, and we will try to figure this out.

  9. Hi
    I have a case.If i type a text "IN" in cell A1, the next cell B1 should be blank.No other values could not be typed in that cell.in same way if a description is already in cell B1 and if I type text "IN" in cell A1 it should get automatically deleted.Pls help me out.

    1. Hi David,

      If column B already has any values, I think conditional formatting won't work. This task requires a macro and you can try to find an example on some Excel-targeted forums like mrexcel.com or excelforum.com. I am sorry for not being able to help you.

  10. Hi Iam trying to enter a formula that returns the following

    In cells in Column J I will be entering employee names against locations in Column K, I then need Column M to return programmed and the whole row to be highlighted in Green,

    However if Column J returns RBS I need column M to return programmed but the row to be highlighted blue

    1. Hi Simon,

      I am sorry, I do not understand what "to return programmed" means and what RBS is. Can you please clarify?

      1. Hi

        What I would like to achieve is:-

        I have 15 employees who work in different teams, I would like to set up a formula that when I type the employees name (ie C Reed) into cell K2 cell N2 is populated with the word Programmed and the entire row is highlighted in green, but if I typed RBS into cell K2 Cell N2 is still popultaed with Programmed but the row is highlighted in blue.

        Thanks for helping

        1. Hi Simon,

          Thanks for the clarifications. Then you can try creating 2 rules with the following formulas:

          Blue: =AND($K2="RBS",$N2="Programmed") This rule should be the first in the list, with the option "Stop if true" checked.

          Green: =AND($K2<>"",$N2="Programmed")

          1. Hi Sorry

            I dont think I made it clear that if I typed RBS or my employees name in to cell K2 I would like the word Programmed to automaticaly appear in Cel N2 and the row to either highlight Blue if Cell K2 contained RBS or Green if an employees name is typed into cell K2

            Thanks for your help

            1. Hi Simon,

              Just enter the below formula to cell N2, and then copy it across the entire column:
              =if(K2<>"","Programmed","")

              This formula will enter the word "Programmed" in column N once you type an employee name in column K in the same row.

              And then, you can create the conditional formatting rules with the formulas I suggested earlier to color the cells in the way you want.

  11. I tried using this formula but then after it satisfies the first input value it will not do numeric series when inputing the next value

    =IF(ROW(A1)<=$D$7, ROW(A1), "")

    1. Hello!

      And what values do you have in other cells of column D and why do you compare with A1? If you can send us a sample workbook at support@ablebits.com, it would be much easier for us to suggest a proper formula.

  12. Hello, I want to create a numeric series starting with 1 based on the value entered in a column.
    For example:

    In column d, row 7, the value entered is 3, then column e, will automatically enter number 1, 2, 3 to rows 7-9.

    Then if I enter another value on column d, row 10 say for example 2, then column e will automatically enter 1 and to to rows 10 and 11.

    Please help

  13. I am creating a scheduling template for a staff of hundreds of employees. I need to make sure I do not schedule an employee wore than 5 days in a given week. How can I highlight cells if a specific name occurs in a block of cells, say b7 - h15, more than 5 times?

    1. =COUNTIF($B$7:$H$15,B7) >5

      figured it out.

      1. OK, here is a step further. Is there a way to highlight cells based off the same block of cells over multiple tabs. I tried "=COUNTIF('Batch Review:Rotary Opener'!$B$9:$H$28,B9)=1" and received and error saying that I could not use this reference in conditional formatting.

        1. Hi Brian,

          Conditional formatting rules require a more traditional formula format : ) Try out this one:
          =(COUNTIF('Batch Review'!$B$9:$H$28,B9) + COUNTIF('Another sheet'!$B$9:$H$28,B9) + COUNTIF('Rotary Opener'!$B$9:$H$28,B9) ) = 1

    2. Hi Brian,

      Try creating a rule with this formula:
      =COUNTIF($A$2:$A$20,A2)>5

      Where A is the column containing the employees names and A2 is the first cell in a block with a given name. Please pay attention to the use of absolute and relative cell references.

  14. Hi,

    Please help
    I have 2 sheets. I have a list of items on 1st sheet, it has item code (A1) next to it is description (B2) and so on.

    I am making sheet 2 with description only (populated from quickbooks). How do I make a formula to add the item code corresponding to its description on a cell next to it.

    Not all items are in the 2 sheet and they are in different order compared to the 1st sheet

    Thanks in advance

    1. Hello Eric,

      You can do this using a VLOOKUP formula similar to this:
      =VLOOKUP($A2,Sheet1!B2:C20,2)

      Where A is the column with descriptions in your Sheet2, B is the column with descriptions in Sheet1, and C is the item codes column in Sheet1. Please note that the VLOOKUP function cannot search on its left, therefore the Descriptions column (in Sheet1) should the the left-most column in your lookup range.

      Please see the following tutorial for more info:

      Excel VLOOKUP tutorial for beginners - syntax and formula examples

      Advanced VLOOKUP formula examples

  15. Hello,

    I have been working on a pivot table for receiving of parts for a specific product. Different parts for the product are received from different vendors. I am creating a file that will take raw data from sheet 2 and easily show and format the cells for each grouping of products when all the parts have been received.

    For example, product 1 is listed 10 times in column A because it has 10 parts to it before it can be built. Column C shows if the part for the product has been received. What I would like to have done is once the report I paste into sheet 2 shows that all parts have been received for product 1 in column C, to then highlight the name "Product 1" in column A in green. I would also like this to repeat automatically for every other product in column A when all parts in column C are showing received.

    Thanks for any help!

    1. Hi Josh,

      It looks like this can be done, but we need to see the structure of your data to be able to say with certainty and suggest a proper formula. If you send me your sample workbook at support@ablebits.com, we will try to help.

  16. Thank you, Svetlana.

    Very useful, although if you know a way I can run this without having to create an additional column that would be even more awesome! :)

    Pri

    1. Sorry Pri, I don't know such a way :( I can only suggest hiding that additional column.

  17. Hi Svetlana

    Hope you can help. Would you know how I can apply conditional formatting to a table where the row colours alternate as the column value (text) changes?

    For example: the column values are car, house, bird, table, anything else, and when the value changes, the row colour changes (2 colour choices). I can't apply a colour to each value as they are not all known. I just want two colours to alternate as the value changes so it's easy to spot the change.

    Thanks in advance.

    Pri

    1. I hope this is not a "too late" comment: you can apply a new rule to the same range. The only condition is that you do not apply the same format for different values. Now: if you do not know what are the values (as they will be appearing appear in your table) you can have a list of new values and mark in your table any new item (not contained in your list) with a special color or mark. You can use a formula from LOOKUP or similar do detect if your table has or not the "new value" in your master list...

  18. Hi,
    I have a workbook where I have work order numbers in column a and start dates in column f, in another sheet I have work order numbers in column d and start dates in column h. I need to be able to highlight a row if I have 2 different dates for the same work order number - Thank you so much

    1. Hi!

      Simply select the table where you want to highlight rows (without column headers), let's say in your sheet 1, and create a rule with this formula:
      =$F2<>Sheet2!$H2

      Where F2 is the top-left cell with dates in sheet 1, H2 - the top-left cell with dates in sheet 2, and Sheet2 - the 2nd sheet's name.

  19. Hi - this is a very useful site! I need to format cell C5 to say 'YES' if cell B5 is greater than 100, and for C5 to say 'NO' if it is less than 100. I am sure that this is very simple but I can't work it out! All conditional formatting seems to be to colour a cell or text, but not to put a work in a cell… Thank you :)

    1. Hi Lisa,

      You are right, this is simple, and conditional formatting is not needed :)

      Just enter the following formula into cell C5:
      =IF(B5>100,"YES","NO")

      1. Thank you so much! Now that makes sense! I have come across this before but must have completely forgot. Thanks again :)

  20. Hi
    I need to highlight any cells that contain an absolute value rather than a formula i.e. the formula has been overtyped with a value. Is this possible with conditional formatting?

    1. Hi Chris,

      If you use Excel 2013, you can create a conditional formatting rule with the below formula (where A2 is the top-left cell of your range):
      =ISFORMULA(A2)=FALSE

      If you use Excel 2010 or lower, you will have to add User Defined Function (VBA code) to your workbook because ISFORMULA was introduced in Excel 2013 only. Here is the function:

      Function IsFormula2010(ByVal cell As Range)
      IsFormula2010 = cell.HasFormula
      End Function

      If you do not have much experience with VBA, these step-by-step instructions will be helpful.
      After the above code is added, you can create a condition formatting rule with the same formula:
      =ISFORMULA(A2)=FALSE

  21. Hi Svetlana,

    I feel I'm really close to receiving an answer in this article. If you see "Compare 2 Columns for Duplicates", it doesn't have an explanation as to how I can have excel put these matching cells on the same row (your picture is a great example of my problem). I need them to be on the same row because I have data attached to the duplicates that changes monthly (however, the name remains the same). Do you know how I can have the rows match up?

    Thanks in advance for your assistance!

  22. Hi
    I have a roster schedule that uses conditional formatting for each day based on where the employee is (OT/ AL/ Work/ Off tour etc) What I would like to do is highlight the entire column of what day it is today.

    Ie column HE is today's date (29 July) I would like the entire column (which has other conditional formatting values and then blank cells) to be a certain colour so it is easier to navigate back to what day it is.

    I have the 'TODAY' date formula in cell A1.

    Have tried various ways and can get the single cell (HE) to highlight, but not the entire column.

    Thanks for any help

    1. Hi Sarah,

      I think you can handle it in this way:

      - Select the entire table without column headers and create a rule with either formula:
      =A$3=TODAY() or =A$3=$A$1

      Where A is the first (left-most) column of the table and 3 is the row with dates (table headers).

      Depending on what you are trying to achieve, this rule should be either the 1st or the last in the list of conditional formatting rules.

      If it is the 1st, the column will change the color but individual cells might get colored in different ways based on your other rules. If it is the last, the entire column will change the color overriding all other rules.

      1. OH THANK YOU Soooo much! First formula worked a treat.

  23. Afternoon

    I am trying to get a cell A2 to fill green if cell B2 says Approved or fill amber if cell B2 says Pending. Cell B2 will always start at Pending and then will be overtyped with Approved as and when, and would like cell A2 to update itself based on this change. I have tried a number of ways, but can only seem to get the formatting to change for one or the other not both. I'm sure I have used conditional formatting for something like this before. Is there anything you can suggest?

    Thanks :-)

    1. Hi Alison,

      You simply have to create 2 rules with different colors for column A:
      Green: =$B2=”Approved”
      Amber: =$B2=”Pending”

      Did it work?

  24. DEAR SIR/MEM

    WHEN I SELECT ROW AND COLUMN ITS NOW SHOWING IN NORMAL BLUE COLOR

    ..I WANT TOSAY THAT WHEN I DRAG A CELL ITS NOW SHOWING THAT I M SELECTING

    HOW CAN I SOLVE IT PLZ REPLAY WITH ANS..

    UR FAITH FULLY USER
    CHANDRESH VAVADIYA

    1. Hello CHANDRESH,

      I am very sorry, but I do not understand your question. Anyway, I believe the issue does not relate to Excel conditional formatting.

  25. I have a problem in excel format date is in one sheet and my condition
    =if(mid(sheet!y6,11,5)='F316L','XXXXXXXX',YYYYYYY)
    THIS IS WORKING OK WHEN THE DATA IS F316L BUT WHEN DATA IS ' 12 '
    VSD

    Reply

    1. Hi SHARADA,

      Sorry, I am not sure I understand your formula. Why are 'XXXXXXXX' encapsulated in apostrophes while YYYYYYY aren't? And what is '12' VSD? I think it will be easier for me to understand if you can provide a sample of your data.

  26. Hello,

    I tried to send my sample workbook but I keep getting an error!

    It says: "The error that the other server returned was:
    550 5.1.1 : Recipient address rejected: User unknown in virtual alias table"

    Please help!

    Thanks!

    1. Sorry, Carl, this is my fault - there was a misprint in the address. Don't know how that could happen, I typed it hundreds of times... Here is the correct one (double checked : ) - support@ablebits.com

  27. Hi, first thanks for your great blog!
    I am trying to get the cells on column A to change to green when F, G and H contains "Done" or "N/A". I has tried a couple of different formulas but no luck.
    It should be something like:
    =AND((OR($F$3="Done");($F$3="N/A"));(OR($G$3="Done");($G$3="N/A"));(OR($H$3="Done");($H$3="N/A")))
    If you find some time, can you guide me to the right solution please?

    1. I found a working solution :)

      =AND(OR($F3="Done";$F3="N/A");OR($G3="Done";$G3="N/A");OR($H3="Done";$H3="N/A"))

      1. Excellent! Sorry for not being able to respond earlier, this is because we do not monitor comments on weekends :)

  28. Hello,

    I have conditional formatting on my dates and they turn color based on 30, 60 90 days past due date. What i need next is to change my status column to match the date colors. I have status' of Open and Closed. If they are open they should match the color of the date, red, orange or green if over certain days, if it is closed it can remain black. Any help is appreciated.

    1. I forgot to mention I was using this formula with no luck - just turns everything red for open =IF($K2>30,$C2="open","")

      1. Hi Michelle,

        I'm not sure I completely understand the task, so let me check. You have a status column C that contains words "Open" or "Closed", this is absolutely clear. You have another column K with what kind of entries - numbers or dates?

        If numbers, you can change the color of your Status column by creating 3 conditional formatting rules with a simple formula like this:
        =AND(C2="open",K2>30)

        If dates, then please provide more details on how you determine the past due date. If you can send me your sample workbook at support@ablebits.com, this will be a faster way : )

        1. Hello,

          they are dates. They turn color based on 30, 60 and 90 days past the due date. I need the status column to do the same if they are Open and Closed so that we can monitor what is not done on time. Maybe there is another way?

  29. Hello,

    If I have a set of numbers is there a way I can use conditional formatting to highlight the number in that set that is closest to zero?

    1. Hello Jessica,

      Thank you for your interesting question!

      If your data set consists of positive numbers only, you can use this simple way:
      - Select your data set.
      - Click Conditional formatting > New Rule... > Format only top or bottom ranked values.
      - Under "Format values that rank" section, select "Bottom" from the drop-down list and put 1 in the box next to it.

      If your data consists of both positive and negative values, then a solution is a bit more complex. I've added a couple of examples to the post because this is really a very interesting question and other users may find the examples helpful. Please see How to highlight the nearest value in a data set for full details.

  30. Hi,

    I have conditional formatting set so that the fill turns green if it equals a certain number. There are 5 numbers that meet that criteria in a row, 4 of them turn green and the 5th one does not. They all have the same formats and formulas. Do you know why it is leaving out that one number?

    Thanks!

    1. Hi Mike,

      The most obvious reason that comes to mind is that the format of the problematic number is different from all others. You can try to copy the format from some other cell where the rule works well to that problematic cell using Excel's Format Painter. Also, make sure your formatting rule applies to the entire rows. If neither is the case, you can send us your workbook at support@ablebits.com and we'll try to figure it out.

  31. Nevermind...figured it out. I'm dumb

    1. Hi Jared,

      As I see in the comments timestamps, it took you just 16 min to figure out the solution. So, you definitely are not : )

  32. I am making a spreadsheet and want to highlight specific duplicates. Like if a name pops up 3 times I want it green...4-9 times I want yellow. and 10+ times to be in red or something. What rule do I want to set up for this? Do I have to find the first instance of a name and create each rule based on that?

  33. Svetlana,

    Thank you very much for your time on this. That was helpful and again informative. I will use this suggestion.
    You have an awesome blog here. Thanks.

    Make it a great day !

  34. I have a situation in which I'm applying conditional formatting to data that can be in three different ranges. For example if a cell has a value below a certain number, it colors green, if it is between two values, it colors yellow and if it is higher than a value, it colors red. I have this part down with three separate rules.

    However, these ranges will change based on gender, which I have in an earlier column. Therefore, there are two different sets of three rules I want to apply to a row of data. What I want is that if C3, for example, reads female, then three specific conditional formatting rules will be applied to J3 which would be different than if C3 read male.

    I would love any help you could give me.

    Thanks!

    1. Hi Carl,

      It is not possible to create a conditional formatting rule that would force another rule or set of rules to apply to a certain range of cells. Instead, you can create 6 separate rules combining both conditions in one formula, e.g.:
      =AND($D3>0, $C3="male")

      If you are looking for something different, please send me your sample data at support@ablebits.com and we will try to figure out the proper formulas.

  35. Thanks for this awesome blog !!!
    Yet i could not crack this.

    I have value in cell a1 to a5 and b1 to b5. Column a is output of path1 and column b is path2. Now i need to compare value of column b with column a and color column c with 3 colors using data bars to show the magnitude.
    1) green : if column b value is lesser than a
    2) yellow: if column b value is equal to column a
    3) red : if column b value is lesser than column a

    Now the c column should have a data bar to indicate how good or bad the value in column b is compared to column a. I spent too much but i eventually end up forgetting my location !
    Can you shed some magic on this please

    1. Hi Amarnath,

      3 data bars of different colors cannot be displayed at the same time in one column. But you can try this way:
      - Enter the following formula to cell C2 that will calculate the difference: =B2-A2
      - Copy the formula across the entire column C.
      - Apply the Green Data Bar to column C (negative values will be colored in red).

      To hide the values and leave only the data bar visible, click 'Manage Rules' under Conditional Formatting, double-click your Data Bar rule and select the option "Show Bar Only".

      As an alternative, you can consider using sparklines.

  36. I am trying to do some Dynamic highlighting bas on a data validation list. My issue is when I create my conditional formatting formula =$J45=$E$40, the dynamic is only work for 1 value. When I switch values in the dropdown, the formula no longer works for the table range. Why is this?

    1. Hello Bethany,

      It's very difficult to say what the problem may be without seeing your data. Your formula works for column J only since you use an absolute column reference. Is this correct? Anyway, if you can send me your sample workbook at support@ablebits.com, I think we will be able to help better.

  37. How do I test for the value of a cell color? I have a spread sheet where my customer combined rows of the same kind with a cell color. They did this manually. However I need to export this to a publishing program so is there a search for this? In the past, before the customer used color fill, I tested the data (=IF(F319=F320,"","{RULE}") and then I was able to place a rule below each group. Now with the cells filled with color, I'm at a loss.

    Thanks!

    1. Hi Steve,

      You can use a user-defined function to count color-codes cells, we provide the ready-to-use code in this article - How to count and sums cells by color in Excel. You will need only the GetCellColor function that returns the background color code of the specified cells. You can use this function within your IF formula like this: =IF(GetCellColor(F319)=GetCellColor(F320), "","{RULE}").

  38. Hi! I'm having a problem figuring out how to get conditional formatting to work in the following scenario.

    I have a 3 column table. A and B will either have "Yes" or "No" as values. If both A and B = Yes, I want to highlight that row green. If both A and B = No, I want to highlight that row red. And if A and B have differing values from each other (e.g. A=No, B=Yes), I want to highlight that row yellow.

    I'm pretty sure I need to have 3 different rules, but other than that, I'm not sure where to start. I feel like this must be easier than I'm making it but I'm not sure how absolute and relative cell references work, and I think maybe that's part of my problem. Any help you can provide would be greatly appreciated! Thanks so much!

    1. Hi Jen,

      Right, you will need 3 rules with the following formulas:

      Green: =AND($A2="Yes", $B2="Yes")
      Red: =AND($A2="No", $B2="No")
      Yellow: =$A2<>$B2 (in plain English, the <> operator means "not equal to")

      As for the cell references, I will try to explain in more detail:

      - Absolute cell references (with the $ sign) always remain constant, no matter where they are copied. Because you always compare values in columns A and B, you should use an absolute column reference. As you can see, the dollar sign ($) appears before all column letters in the above formulas.

      - Relative cells references (without the $ sign) change based on the relative position of rows and columns, when copied across multiple cells. Since you need to compare values in each row individually, you use relative row references in the formulas.

      In conditional formatting rules, cell references are relative to the top-left most cell in the applied range. So, you can simply pretend as if you are writing a formula for the top-left cell only, A2 in our case.

      Absolute and relative references in conditional formatting formulas behave in the same way as in usual Excel formulas (as described above). So, because you use relative row references, your formulas will "get changed" for each row and compare the values in columns A and B in each individual row. I hope this makes sense :)

      1. Svetlana,

        Thank you so much for explaining the absolute and relative cell references. I looked it up more after I posted my question, but you've explained it better than anything else I've found!

        As for the conditional formatting formulas -- I had the red and green rules correct, except for the mixed references; the yellow formual I did not have correct and I'm not sure why I failed to find such an easy solution. The not equal to operator makes perfect sense.

        Thanks so much!
        Jen

  39. I have columns with dates in them. Each row is a different activity and the columns represent different schedule versions. If column C has one date and then a different date in column D, I want column to highlight in a color depending on if it occurs before or after the date in column C. I want to carry this down across several rows, but for some reason the conditional formatting is based only on the first row of data. How can I get the conditional formatting to apply to each individual row?

    1. You just need to use an absolute column and a relative row in your formulas. Please try these ones (assuming that row 2 is your first row with data):
      =$C2>$D2
      =$C2<$D2

  40. Hello,

    I am wondering if there is a way to apply icons to words and not just numbers.

    For example the icons are in column B and I would like the "green check" icon to display when column J reads "YES".

    Is that possible?

    1. Hi Kathleen,

      You can do this with the help of this formula =IF(J2="YES",1,""). Copy the formula all across column B, starting from cell B2.

      Then create an icon set rule and set a green flag for values >=1. Remember, to select the option "Show icon only".

      1. Can you do this for more than one cell? I need to do this for my spreadsheet but I have many many rows and would like to use one general rule rather than a rule for each line. But I also want to be sure that it's looking at each line to format and not just the first one and carrying that cell's value forward for the formatting of the rest.

        For example, Column B contains either a "Yes" or a "No" for each row and I want the corresponding cell in column P to have red fill if Column B for that row is "No."

        1. I figured out a workaround. Ideally I wanted my Column P to be filled but for now I've inserted a column that puts a Red X as you suggested in your reply to Kathleen.

          1. Hi Mallory,

            The beauty of Excel conditional formatting is that you don't need to create a rule for each row! Just apply the rule to as many rows as you want to color, write the formula for the first row using a relative cell reference (like A1) or mixed cell reference (like $A1), and Excel will compare the values in each row, like it does when you copy a formula down a column.

            In your case, you could create 2 rules, say for P2:P1000 (where P2 is the first row of data), with these formulas:

            =$B2="yes" and =$B2="no"

            For more information, please see Relative and absolute cell references in Excel conditional formatting rules.

  41. Hello,

    This already looks like an oracle now. I have an other challenge with duplicates. I have a file with different sheets. In Sheet D there is a cell that fills automaticly with information from the other sheets. I use this to generate Meta data for my website which I can import.

    Some of the data in Sheet D are duplicate. I like to make a rule which will change the data in this sheet/cell automaticly if the outcom of the formula used in Sheet D , Cell A is a duplicatie with a cell above in the same column.

    I hope you can help me with this info.

    Thanks

    Rutger

    1. Hi Rutger,

      Try creating a rule with this simple formula =A2=A1 where A2 is the top-left most cell in the range where you want to color the duplicates and A1 is a cell above. This rule will color the second duplicate occurrence. If you need to highlight the first one as well, create one more rule with this formula =A2=A3.

      This solution works fine for one and several columns, except for the case if you have data in row 1. Hopefully this is not the case and you have column headers there : )

      1. Hi Svetlana,
        First what an amazing blog, I only occasionally use excel I had no idea it could do so much!!
        My problem is that when I use the formula =D3=C3 to highlight duplicates (where the first cell of data is c3) it highlights the first occurrence of the duplicate, not the second. I don't need the first highlighting but I do need the second. I don't know what I am doing wrong.
        Please help and keep up being the excel fairy!
        John

        1. Hi John,

          Thank you so much for your kind words.

          The formula I suggested for Rutger is purposed for highlighting duplicates in the same column. As far as I understand, your formula is comparing cells in columns D and C, in the same rows. So, if you want to highlight only duplicate values in column D, the formula will work, just make sure the rule applies solely to this column.

          If you are looking for something different, please provide a bit more details.

          1. Hi Svetlana,
            Thanks for the response. Yes it does highlight the duplicates but it highlights the first example not the last. I don't want the first highlighting. So I need to know if a value has been repeated on the same row. So imagine 3b, 3a, 3a, 4c on a row of data I would only want the 2nd 3a highlighting not the first one. Using the formula you gave it highlights just the first ie: 3b, 3a, 3a, 4c. I don’t want this.
            Also I need it to highlight multiple duplicates and non consecutive duplicates. I need it to 2b, 2b, 2b, 2a . I also need it to do 2b, 2a, 2b, 3c,. So in all the examples I need only the second repeat to be highlighted. Hope you can help.
            Yours
            John

            1. Hi John,

              Got it, please try this one:
              =COUNTIF($A3:A3,A3)=2

              Where 3 is the first row and column A is the left-most column with data. The rule shall be applied to all columns (not including the header row), though only the left-most column is included in the formula.

              1. Wonderful Svetlana,
                You are a genius and a true excel fairy. Many thanks indeed.
                John

  42. Hello,
    My conundrum is this:

    Cell I13 has zero formulas nested and only represents whatever number i type into it. I need the text or fill in cell I13 to be green if it's value is greater than or equal to the value in cell I14 and I need the color to be red if its value is less than the value represented in cell I14. I14 has a nested formula which represents a numerical value from cell D4. I have tried the Conditional Formating rules to no avail; is this algorithm even possible?

    1. Hello PH,

      I've just tried creating 2 rules for cell I13 with the following formulas, and they worked just fine:

      Red: =$I$13<$I$14 Green: =$I$13>=$I$14 My cell I14 has a simple formula =D4, though in theory this should not make any difference. If the above formulas do not work for you, please specify which exactly formula you have in I14 so that I can test on the same data.

      1. similar to the question above, i want a conditional formula that i can apply to multiple cells in a range. if a cell contains a number > the number in the cell above, i want green; if the cell contains a number < the number in the cell above, i want red. i would like to drag this condition all the way down the column. is this possible?

        1. nevermind. i think i figured it out. you can delete my thread.

  43. I am trying to find a formula to highlight the entire row based on the conditional formatting of one column.

    I formatted column 1 to highlight duplicates, and I want excel to highlight the entire row if there is a duplicate.

    Is this possible?

    1. Hello Sarah,

      Of course, this is possible. You just need to extend the range for the formula to get applied to the entire table rather than 1 column. Simply open the Conditional Fromatting Rules Manager and change the range in the "Applies to" box.

      As an example, please see "Check for duplicates across multiple columns" in this article. As you see in the screenshot, the formula applies to the range A2:C9, and as a result the entire rows are highlighted based on cell value in column C.

      1. Thank you! The second suggestion worked!

  44. I am having an issue with using conditional formatting on my excel project. I want to highlight each number in a row that is different from each other in one single conditional formatting formula. How would I do that?

    1. If my understanding is correct, you need to highlight unique values in each row. If so, the following formula will work a treat, where A is the first column and H is the last column with values:
      =COUNTIF($A2:$H2,"="&A2)=1

  45. Hi, i want to format a cell based value of different cell. Please let me know how to do it.

    Ex: If value in Cell E2="Yes" the F2 cell needs to be in date format.

    1. Hi,
      I have an answer for this if you can explain in brief..
      Thanks,
      Hitesh

    2. Hi Naveen,

      I'm sorry, I do not have any idea on how to do this. I'm not even sure this is possible in principle.

      1. Use the Formula for conditional formatting E2="Yes" and set the format section to date format you want, but you do that in the cell you want to format. You still have to enter the date in that cell.

      2. =OR($E2="Yes")

  46. Hi! was wondering if you can help me with something on the similar subject.

    Column A + Column B = $F$5

    A Basic example is Column A has 2.70, 5.40, 8.10 Column B has 10.80, 21.60, 32.40 if I put 13.50 in the box I'd like the 2.70 in Column A and 10.80 to be highlighted in Column B etc.

    I've tried different ways like =A3+B$3=$F$5 and/or =B3+A$3=$F$5 but nothing seems to work can you help me.?

    Thanks

    1. Hi Derek,

      You were almost there : ) You need to create a separate rule for column A and column B with this formula: =$A3+$B3=$F$5 Please note, it will work for Column A + Column B = $F$5, only if values in columns A and B are in the same row.

      If you want to highlight values in different rows that make a sum, you will need a bit more complex formulas:
      For Column A: =ISERROR(MATCH(ROUND($F$5-$A1,10),$B$1:$B$10,0))=FALSE
      For Column B: =ISERROR(MATCH(ROUND($F$5-$B1,10),$A$1:$A$10,0))=FALSE

      1. Wow that's a lot more complex than I thought it would be lol
        Ok last question I promise if I wanted to add one more column later what would I input?
        Thanks so much for your help I couldn't have worked that out for myself

        1. Hi Derek,

          I'm glad to know the formulas have worked for you : )
          If you are asking about the 2nd case (sum in different rows), regrettably it's not possible to do in 3 columns (i.e. A + B + C = $F$5) using conditional formatting formulas, at least I do not know any way. This would require 2 nested loops, which can be done as a macro only.

  47. Hi! I have a bit particular case. I have to find duplicates (max 5) in column A worksheet_1 and copy only one of each duplicate in column A worksheet_2. Then I have to copy values from B worksheet_1 that correspond to each duplicate in B1:F1 of worksheet_2.

    For example:
    worksheet_1 worksheet_2
    A B A B C D E F
    1 kl5f 1 k15f ozpp
    2 l9j8 2 l9j8 kol
    6 yu60
    2 kol
    1 ozpp

    Thank you in avance

    1. i have a work sheet, many column,in a column many date are 14/15/16/17 if 15> then total row move to another sheet automatic

      1. Hi,
        Can you please give an answer of conditional formatting which is compared above for two columns where in countif formula has been used. Can you please brief. Because that scenarion is exactly with my question but in that i found one querry which is -

        Products are mentioned in column a and sales vales are mentioned in the other column. The conditional formatting which is used in that is not exactly giving the actual reaults.

        Because i hv seen and practically applied..
        scenario-

        Product1 2
        Product2 4
        Product3 6
        Product4 3
        Product1 2

        Here if product is matching and if the aale value that is matching then it should highlight both with the help of cnditional formatting however its still highlighting incase product one is mentioned two times and sale value ia differerent. So in that case it shiuld not highlight but its highlighting.
        Plz assist to resolve this scenario.
        Thanks in advance...

        1. Hi Svetlana,
          Thanku so much. Its really awsome. My question has been reaolved. But there is a small thing which i wanted to add in.
          The scenarion which i discussed below related to conditional formatting by using countif formula.

          But the first product no. And sales value is not highlighting except that its highlighting from the below duplicate.ex-
          Below is tge scenario resolved with sugesstions provided by you. But firat plan is highlighting with by using countif formula and the next plan no. Which is 12345 and the same amount i.e.:-200 is highlighting

          Plan no. Name amount column d
          12345 a 200 =concatenate
          (A,b,c)
          135937 b 300
          847474 C 400
          92828 d 500
          12345 a 200
          95850 e 600
          12345 a 100

          Please assist and advise if i can through these duplicate plans in another or sheet 2 without help of macro...

          Thanks in advance....

          1. Hi svetlana,
            Can you please provide an update on above question..
            Thanks,
            Hitesh

        2. Hi Hitesh,

          There are two ways to fulfill your task: using a helper Column or our Duplicate Remover add-in.

          If you choose the former, do the following:
          - Add a helper column to your table, e.g. column C, and enter the following formula in cell C2:
          =concatenate(A2,B2)

          Where A and B are the columns you want to compare, 2 is the first row with the data.

          - Select columns A and B and create a conditional formatting rule using this formula:
          =countif($C$2:$C2,$C2)>1

          If you use the Duplicate Remover, you won't need to create a helper column and mess around with formulas. Just pick the "Fill with color" option on the final step of Duplicate Remover Wizard.

      2. In this case Excel formulas cannot help, this task can be fulfilled using a macro.

    2. Normally the exemple was suppposed to be with spaces...

      1. Hi Jelena!

        It's a bit difficult to understand what exactly result you are trying to achieve without seeing your data. If you can send me (support@ablebits.com) your sample workbook and the result you are looking for, I will try to help.

        1. what i m trying to do is that, if i enter value in single cell of a row the clour of that row or the selected cells should be changed by entering the data in the cell

          1. If you want to color the entire row based on the data in a certain column, then select all the rows and columns with your data and create a rule using this formula:

            =$C2><""

            Where C is your column, 2 is the first row with data.

            If you want to highlight a row when at least one column contains data, use this formula:
            =countif($A2:$G2,"><"&"")>0

            Where A and G are correspondingly the first and the last columns you want to check.

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)