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 19. Total comments: 1709

  1. Hi all,

    I was wondering if anyone could help me with a conditional formatting formula for the following information?

    I want to compare a 'Grade(1-9)' column with a 'Tgt' column and have it showing as red if it the 'Grade(1-9)' column is less than the 'Tgt'.

    Here is an example of the information in both columns:

    Tgt: 8D 7D 6S 7D
    Grade(1-9): 8D 6A 6E 6E

    Therefore, the 6A 6E and 6E in the 'Grade(1-9)' column I would like to highlight as red as it is less.

    Is this possible?

    The current grading from highest to lowest is:
    9A 9S 9D 9E 8A 8S 8D 8E 7A 7S 7D 7E 6A 6S 6D 6E 5A 5S 5D 5E 4A 4S 4D 4E 3A 3S 3D 3E 2A 2S 2D 2E 1A 1S 1D 1E U

    Would the formula change for each different Tgt value or is there an one fits all formula?

    Thanks for any support or even just a no it wouldn't be possible!

    1. Sorry I forgot to mention that the 'Grade(1-9)' values start at cell E6 and 'Tgt' values start at B6.

  2. Restating my previous question for better clarity -

    I want to format cells in column based on two different conditions applying to the cell in the same row in column A, but the conditions are complicated and I don't know they would look like in a formula. The two conditions are:

    1. If the value in column A is the highest value in column A
    2. If the value in column A is a duplicate value with another value in column A

    ...in other words, if there is "a tie at first place" in column A, I want to make the cells in the NEXT column (column B)for those rows yellow.

    I know my formula for the conditional formatting has to include =AND($A1,)but I am at a loss as to how to describe my two conditions in the formula.

    Thank you for any help you can provide with this knotty problem!

  3. I want to format cells in column J based on two different conditions in applying to the cell in the same row in column I, but the conditions are complicated and I don't know they would look like in a formula. The two conditions are:

    1. If the value in column I is the highest value in column I
    2. If the value in column I is a duplicate value with another value in column I

    ...in other words, if there is "a tie at first place" in column I.

    I know my formula for the conditional formatting has to include =AND($I1,)but I am at a loss as to how to describe my two conditions in the formula.

  4. I am trying to apply conditional formatting based on the following and am getting very confused!

    I want column A to change colour based on the following:

    Col D has a date – YELLOW
    Col E has "Y" – ORANGE
    Col F has a date – PINK
    Col G has a date – DARK BLUE
    Col H has a date – DARK GREEN
    Col I has a value – LIGHT GREEN

    The process should be, as each column has a value or date entered it changes to that corresponding colour, can you help?

  5. Hello

    I am creating a vehicle fleet inspection chart. Vehicles are required to be serviced within every six weeks.
    I have plotted a row of six weekly reference dates for the year based on the last service date from the previous year (E18:N18). Giving me ten dates. The dates in this row indicate that the vehicle must be serviced by each of these dates.
    I have also added a todays date cell (C17)

    I have conditionally formatted these cells to:
    > change to orange if a date is entered that was later than the reference cell.
    > change to green if a date is entered that is less than or equal to the reference cell.
    > no formatting for blank cells and stop if true.

    However, I still require the cells (E21:N21) to change to red if the cell is blank and the reference dates above (E18:N18) are less than todays date. This would show me that no service took place. How can I do this please?

  6. Hi,
    I would like to know the formula for the following.

    Plan Submission Overdue Actual Submit Date

    9-Feb-18 13 13/2/2018
    8-Feb-18 14 13/2/2018
    5-Feb-18 17 5/2/2018
    5-Feb-18 17 5/2/2018
    1-Mar-18 -7

    Condition as follows :
    >>If Actual submit date is blank and overdue (due previous week) , Plan submission date highlight grey.
    >>If actual Submit date is blank and overdue this week, plan submission date highlight grey.
    >>If actual submit date not blank, no need to highlight.

    Hope you can help with this. thanks!

  7. Thanks so much, This article was very much helpful.

  8. My spreadsheet has a last revision date column with a date and a "Date of next review" column next to it with the formula of =S114+365. I would like to have the "Date of next..." to be highlighted if it is within 30-60 days yellow and less than 30 days in the future as red

    formula =AND($A2-TODAY()>=30, $A2-TODAY()=1, $A2-TODAY()<30)

    isn't cooperating, any help is much appreciated

  9. Hello,

    i m trying t create an auto border with conditional formatting, since my cells are havign formulas, the border are getting displayed, even though the cells are empty.

    i have to make the cells between B21 to h35, whenever my results there in the rows the border should be auto

    the following formula i have tried, with various methods, formats etc...

    =OR($B21"",C21"",D21"",E21"",F21"",

    Please guide me

    thanks in advance

  10. Hi,

    I am trying to format cells that are a formula =(A1/B1) with percentage as a result in the C-column.
    I am using Icon sets and have put in;
    red 80-100%
    yellow 50-79%
    red 0-49%
    I have tried both with Number, Percentage, Percentile and Formula.
    It works only when I have one cell that has become 100%, otherwise it will not show the right color. It is like the colours only works in relation to the highest amount put into the column? I do not always have the 100% but I still wish it to work according to the colors.

    Please help, I hope I have made this clear enough.
    Sofie

  11. Need to colour based on other cell value like.

    If B2 value has a maximum valie in range of B1:B5 then only A2 cell colour with yellow.

    What formula i use in conditional formatting?

    1. Hello,

      Please create a custom Conditional Formatting rule for cell A2 using this formula:

      =B2=MAX($B$1:$B$5)

      Hope it will help you.

  12. Hello,

    I have this

    =OR(O16=$AB$23;O16=$AC$23;O16=$AD$23;O16=$AE$23;O16=$AF$23;O16=$AG$23)
    apply for O16:AH21

    I want to apply for AB23:AG23 from range O16:AH21... little help.

    1. Hello,
      For me to understand the problem better, please send me a small sample workbook with your source data and the result you expect to get to support@ablebits.com. Please don't worry if you have confidential information there, we never disclose the data we get from our customers and delete it as soon as the problem is resolved.
      Please also don't forget to include the link to this comment into your email.
      I'll look into your task and try to help.

  13. Is there any way for me to apply conditional formatting to a column that highlights only specific cells in that column that have blanks in the row that the cell is in? Such as highlighting cells only in column B where there are blanks in specific rows in column A.

    1. Hi Dan,

      Simply, make a rule for column B with this formula:
      =$A1=""

      Where A1 is the top-most cell of the applied range.

      For example, if you are setting up a rule for B2:B100, then use the formula =$A2=""

  14. I'm trying to format a cell on a separate sheet to be highlighted based on if multiple cells have at least a value of 1 in it. For example, I have 4 cells and each cell needs to to have at least a value of 1 for the cell on the other sheet to be highlighted. Can this be done? If so, how? Thanks.

    1. Hello, Matthew,

      Try the following:
      Supposing that your 4 cells are in Sheet2, you need to create a rule for conditional formatting like this:
      =AND(NOT(ISBLANK(Sheet2!A1)),NOT(ISBLANK(Sheet2!A2)),NOT(ISBLANK(Sheet2!A3)),NOT(ISBLANK(Sheet2!A4)))

      Hope it will help you!

  15. Hi!

    Would explain more about the part below that how the function works in order to ignore the 1st occurrences and not highlight it?

    "Highlight duplicates without 1st occurrences
    To ignore the first occurrence and highlight only subsequent duplicate values, use this formula: =COUNTIF($A$2:$A2,$A2)>1"

    Thank you in advance.

  16. I have an excel sheet where the county is listed in one column. I would like it to say "yes" in the column next to the County" column if the county is considered economically distressed. How do you write a formula to say "if this cell says Lake, Lauderdale, Haywood, Hardeman, McNairy, Perry, Wayne, Grundy, VanBuren, Bledsoe, Pickett, Scott, Campbell, Union, Claiborne, Hancock, Cocke, then the adjacent cell should say YES"?

  17. Hi
    Desperately Need your help :)
    I have a dates column AC2:AC37 and i also have a price column M2:M37. Once a date in the AC column has got to today date i want the matching price cell in column M to be highlighted.

    looking forward to your response.

    1. Hi Danial,

      Select cells M2:M37 and make a rule based on this formula:
      =AC2=TODAY()

      This will highlight only the prices that have today's date in column AC.

      If you want to highlight the prices matching today's date as well as all previous dates, then use this formula:
      =AC2<=TODAY()

  18. Hello,

    I have conditional formatting in a cell that turns red when it passes a certain date. In the cell next to it I have Status'. I want to shade the cell with the date in it when the cell next to it says "Completed" so I don't still think it's Red/past due. How would this work? Thank you in advance.

  19. I have a problem that I need help with. I am trying to use Conditional Formatting to highlight one cell against another cell using greater than, equal to, and less than. The cell I want highlighted gets its value using a formula that gathers data from multiple areas in the spreadsheet. This seems to be the cause of my trouble. The cell I want to compare it to is a static number. For some reason no matter what I do I cannot get the cell containing the formula to highlight correctly.
    Ive tried all variations of =g3h3 but for some reason it will not work. (G3 is the cell that has a value obtained from a formula)
    What I am looking for is when G3 is less than H3 then G3 gets highlighted red. When G3 is greater than H3 then G3 gets highlighted green. When they are equal G3 stays white.
    PLEASE HELP! I've spent 3 hours on this already.

  20. 1. I have a spreadsheet that data starts at A19:AS100. I want to change font color to "red" for text VA only. In using conditional formatting, Format only cells that contain...I enter VA and have tried entering VA~ also to only change text for VA but it is also changing text color for VAC. Please let me know how I can change text color of VA only not everything that has VA in it or starts with VA.
    2. In the same spreadsheet I am needing to get a total for the following "SUR,HSC,COS,HP" that are listed in cells beginning in column B19:AS100 by name. Names are located beginning A19:A100. There are times that the above list is entered in a cell with other text ex. HSC/CON, DP/SUR and I am needing it to count 1. When it is entered in a cell with two of the criteria listed above ex. SUR/HSC, HP/COS I still need it to count it as 1. I am needing it to count only once regardless if there are two of the criteria to count listed in a cell.

    I would truly appreciate any and all help you can give me on this.
    THANK YOU.

  21. I have 12 columns with turnover and a column with total turnover, would like to highlight, the total as follows;
    if col.1 and col.2 are empty and col.3 and col.4 have data and rest of columns are empty, fill with colour.
    Thanks

  22. What I wanted to achieve is cell formatting depending on the comparison of another two fields that have a date in them (one is a straight date, the other calculated date). If the month in those two dates matches (its equal) then to trigger the formatting (shading) of the third cell.
    A formatting rule of something like
    =MONTH($K21)=MONTH($R12)

    But because this is not a valid formula it doesn't work. I have added this invalid formula here for making my question easier to understand.
    Thank you

    1. Hello, Jack,

      actually, your formula for is correct, if it doesn't work, most likely there's something wrong in your table or you apply the conditional formatting incorrectly.
      If you still require our assistance, please send us your workbook with the data and the result you expect to get to support@ablebits.com. Please don't worry if you have confidential information there, we never disclose the data we get from our customers and delete it as soon as the problem is resolved.
      Don't forget to include the link to this comment into your email.

      We'll look into your task and try to help.

  23. How would I create a conditional formatting rule based on the below formula. This formula is counting (then averaging in a separate, similar formula) worked hours but excludes login and logout times outside of the given range. I’d like to highlight the cells in another column (H:H) that meet the below criteria so that it’s easy to tell which times were actually used in calculating the final formula. For example. If 40 days were “worked” during the selected period, but only 34 days were used to create the result, I want to highlight those 34 cells.

    =COUNTIFS(F:F,">"&M2,F:F,""&M4,G:G,"<"&N4,A:A,"<6")&" days"
    Where:
    F:F = Log in time
    M2 = min log in time
    N2 = max log in time
    M4= min log out time
    N4 = max log out time
    A:A= day of the week in numeric form
    "&M2,F:F,""&M4,A:A,"<6")
    H:H=sum of hours worked (Logout-Login).

    Thank you in advance,

    Anthony

  24. I have a sheet that has various colors based on the cell character:

    "A" = Color Green font
    "R" = Color Purple font
    "C" = Color Blue font
    "I" = Color Red font
    etc..

    But in the sheet there are some cells that identify as "C/R"

    So the cell would have to be C in Blue / R in Purple.
    Two colors in the same cell separated by the "/"...

  25. I want to a cell to default to a text / value if another cell contains specified text/ value

    If cell a1 = text then cell b1 = 135,
    or similar scenarios.

    Thanks
    Pad

  26. Hello,

    I have a spreadsheet with 4 individual columns, then 15 column pairs. Each pair of columns is a set of data from two different sources, sorted by a common key value. What I need to do is highlight the value in the second column (of the pair) of a row that has inequal values.

    I know I can use, for example, =$E2$F2, applied to column $F:$F to highlight values in F that don't match corresponding value in E. But, how do I do this properly over 14 more pairs? Do I need 15 rules?

    Thanks

  27. Hi!

    I desesperally need your precious help please: i have a worksheet with about 70 rows and 52 columns. Each row represents a store/client, the column represents the weekly quantity ordered. Most of the time the quantity doesnt change – except for certain periods. I need to see clearly when the number change. i though conditional formatting could help me but i cannot make it works. I need to compare all the cells to their adjacent cells. I tried the formula = B$3C$3, then i tried = $B3$C3, then without dollar signs … nothing worked (it highlight entire columns rather than cells). I need to automatically highlight the cell that is not equal to the cell to its right.
    Many many thanks in advance!

  28. hi
    this Mohammad Dawood . i from Afghanistan . when i change an alphabeth it have to give a color in the Excell . please gave me Information thanks

  29. Hi,
    I am using few rules for conditional formatting for .csv file. But after the closing the file all rules get deleted. why this is happing? Can we apply this rules for .csv file.

    Thanks in advance

  30. Hello,

    I have a issue that I need help with.
    Basically I have two sheets, one sheet that lists All Items and another that list the Items Sold from the all items sheet. I've used vlookup to pull all the relevant data from All Items for each item on the Items Sold Sheet. Now I want to highlight the SKU that appears in Items Sold in All Items. At the same time All items Sheet has more than one SKU whereas The Items sold has only one. I have used the below formula with Conditional Formatting on the All Items Sheet to try to accomplish this however it highlights all the Skus with a corresponding value from the SKU's column in Items Sold =COUNTIF(SKU, $B2)=1. I want it to highlight all the items sold but only one of the items. Can this be done?

  31. Hello,

    I have one issue,from a selected raw how I can highlight the whole column or selected portion if it identify a preset text or number?

  32. Hello

    Can anyone plz help me for following:

    I have 4 Columns A,B,C,D
    A= Customer Name
    B= Invoice Amount
    C= Due Date
    D= Formula to insert?

    In (Column D) I would like to sum the Invoice Amount(Column B) according to individual Customer(Column A) if due date is today or already past(Column C).

    Example: Today is "29th Aug 2017"

    A(Customer) B(Invoice Amount) C(Due Date) D(Due Amount)
    John $15 29th Aug 17 John= $15+50=65
    Smith $10 25th Aug 17 Smith=$10(Only 1 invoice due)
    Smith $13 10th Sep 17 Obama=No Due
    Obama $18 18th Sep 17
    John $50 28th Aug 17

    Please help.

  33. I'm sorry my question is not coming over correct, 2nd try: I have a spreadsheet with 10,000 rows and 10 columns. Data starts in Row 2, Row 1 are headers. I want all of Row 2 to turn Red if the value in column G, row 2 is =1 then the whole row is Green. I then have to repeat this for the next 9,998 rows.

  34. Hello I have a spreadsheet with 10,000 rows and 10 columns. Data starts in Row 2, Row 1 are headers. I want all of Row 2 to turn Red if the value in column G, row 2 is =1 then the whole row is Green. I then have to repeat this for the next 9,998 rows. Each row should look to it's own row's value in column G. But when I do conditional formatting in row 2 and drag down it will only look to G2 even if I'm in row 3,200 etc. I've tried $G2, and G2 but it will only look at the G2 no matter what row. In closing row 3543 needs to look at G3543's value to decide format. What am I missing? Thank you!

  35. HI
    I want to create a drop down menu that would carry out 5 rows of data.
    ie
    Cash
    100
    200
    300
    400
    500
    How would I achieve this?

    Thanx.

  36. Thanks that formula worked.

  37. =MIN(IF(A4:A94,B4:B9)) =0
    =MIN(IF(A4:A9>4,B4:B9)) = 30.92

    Can you help me with this simple problem.I can't get the top
    formula to work it returns 0.The bottom formula works
    ok.Can't seem to get the 4 to work together.Can you help
    me with this
    A B
    5 30.92
    4 31.29
    2 31.11
    3 31.17
    6 31.29
    7 31.29

    1. =MIN(IF(A4:A9>4,A4:A94,B4:B9)) = 30.92

      Can you help me with this simple problem.I can't get the top
      formula to work it returns 0.The bottom formula works
      ok.Can't seem to get the >4<6 to work together.Can you help
      me with this, I used ctrl,shift,enter
      A B
      5 30.92
      4 31.29
      2 31.11
      3 31.17
      6 31.29
      7 31.29

      1. =MIN(IF(A4:A9>4,A4:A9<6,B4:B9)) = 0 .This is the formula i cant get to work.

        1. Hi, Harold,

          as far I can see, you're trying to use IF function incorrectly. Please take a look at this article of ours to learn more about the syntax of the function.
          You may want to check out this one as well, since it explains how to use IF and MIN together. You fill find a bunch of examples that'll help you to build your own formula properly :)

          1. I didn't make my example ,clear. I have column "A" with these numbers 5 4 2 3 6 7 - In column "B" I have these numbers 30.92 31.29 31.11 31.17 31.29 31.07 If i select a number in column A or an adjacent number I want the minimum corresponding number in column "B" I need a formula for this. I tried this formula but all i get is zero.=MIN(IF(A4:A9>4,A4:A9<8,B4:B9)). i used control, shift, enter.

            1. I didn't make my example ,clear. I have column "A" with these numbers 5 4 2 3 6 7 - In column "B" I have these numbers 30.92 , 31.29 , 31.11 ,31.17, 31.29, 31.07 If i select a number in column A or an adjacent number I want the minimum corresponding number in column "B" I need a formula for this. I tried this formula but all i get is zero.=MIN(IF(A4:A9>4,A4:A9<8,B4:B9)). i used control, shift, enter.I added some commas between some of the numbers to make it clearer.

              1. Thank you very much for the clarification, Harold.

                First of all, please take a look at this part of the article, to learn how to use AND and OR operators in array formulas (* for AND, + for OR)

                Then please try this formula:
                =MIN(IF((A4:A9<8)*(A4:A9>4),B4:B9))

                However, if you're using Excel 2016, the following should do as well:
                =MINIFS(B4:B9,A4:A9,"<8",A4:A9,">4")

          2. thanks i'll take a look

  38. Hello,

    How to make formula for the following:

    if A1=8 then answer is 2
    if A1=10 then answer is 4
    if A1=12 then answer is 6

    Thanks

    1. try this formula
      =IF(A1=8,2,IF(A1=10,4,IF(A1=12,6,"No Value")))

    2. For newer editions you can use =IFS(A1=8;2;A1=10;4;A1=12;6) .. That would save you from nested IFs. But it requires 2016 or newer.

      Old method, =IF(A1=8;2;IF(A1=10;4;IF(A1=12;6;""))) .. It can be shorter if there's no other option than these three, 8,10 and 12. If so use;

      =IF(A1=8;2;IF(A1=10;4;6))

  39. Hi,

    I have a spreadsheet that contains information, I have two search criteria, then when they find a match they highlight the row.
    What I need to do though is - when I put in two search parameters, I want the row to highlight in a different colour.
    At present search one highlights in Green, the second blue.
    Each column after M has a keyword on which I search, and I have upto column AB and down to 20000.
    Hope that all makes sense.

  40. Hi, I'm trying to conditional highlight a cell based on the text in another cell which I can do but I'm having trouble in a particular situation. The formula I'm using is =c6="roller" with green fill format. This works fine except when c6 has its own conditional highlight, which is to display with a red fill with a zero value. If I right roller in an empty cell with no formatting and direct the formula to that cell it works fine. Any help would be greatly appreciated. Thanks in advance.

  41. Hello, I'm having a hard time getting my excel sheet to do what I want...

    If any cell in column G contains "YES" then it turns green. That much I have.

    Now, (if column G has YES) I want column P to highlight RED until it is filled, in which case I want it to go back to no formatting.

    I want the red to prompt me to enter data there when I receive it.

    Is there a simple way to do that?

    Thank you!

  42. Good afternoon
    my problem is
    i want to write in row (A1) 1000 and auto write Sunil in Row (B1) and
    then again write if row (A1) 1400 then auto write Omji in Row (B1) thru conditional formatting

  43. Thanks for the guidance.

    Using your tip, I can conditionally format to color a column depending on whether the next cell to each cell is blank or not.

    it helped in reducing my work.

  44. I'm trying to create a conditional formatting rule, but nothing seems to be working, could you help.

    I like to create attendance tracker sheet and almost completed but one condition format understand.

    In Automated attendance sheet in one employee Cell Condition applied as R (Staff Resigned)then i want to be next all cell range format blank or RRRRRRR..

  45. Hi,
    I want to change the color of the cell depending upon the sum of the column.
    For Example In the below salary column if I enter 10 the color should be green because the sum of column is less than 100.When I enter the next value 50 ,the color should be green since the sum(10+50) is less than 100,
    When I enter 70 the colour of that cell should be red since the sum (10+50+70) has exceeded 100.
    Salary
    10
    50
    70
    Please help me to find a solution.

  46. Hi Svetlana! Thank you for your examples. I have one issue with my excel. Lets say I have Supply time (the old one) and new supply time. I made a conditional formating in a separated row like this new supply time -old supply time and if the result is positivi we have increase in a supply time if it is negative we have a decrease and if the result is 0 we donot have any changes. BUT i have an issue with the decreased supply Hi Svetlana! Thank you for your examples. I have one issue with my excel. Let’s say I have Supply time (the old one) and new supply time. I made a conditional formatting in a separated row like this new supply time -old supply time and if the result is positive we have increase in a supply time if it is negative we have a decrease and if the result is 0 we do not have any changes. BUT I have an issue with the decreased supply time, because I still have some cells that are not fellfield with the new supply time and in my new row it is showing that there is a decrease. What rule to create to highlight the cells that are still not fellfield?
    After that i have to show some results like every week how may items I already fellfield with a supply time how many of them decreased or increased but how can I do this if I’m working with a filter. The function COUNTIF doesn’t work in this case.

    Thank you in advanced!

  47. I'm trying to highlight a cell only if it is a result of a formula. IF the cell is an entered value i don't want the cell formatted.
    I want to highlight only the cells in a column that have values derived as a result of a formula. If the cell has a numerical value entered in the cell i want the cell to remain unformatted

  48. one cell is highlighted with conditional formatting -the rule is if the date is in the next month it will be formatted & highlighted.Now i want to highlight the entire row on the basis of this rule applied on that specific cell.what is the procedure.

  49. Might not be the right section for this, but seems the most likely.

    I am constructing a costing spreadsheet with multiple criteria that will effect the cost of items I work with. What I would like is to have a drop down menu with various 'levels' of input, say 'Super Premium', 'Premium' and 'conventional'. I would then like to have that selection refer to and apply a different numerical value in a formula in another cell.

    I know how to create basic drop down menu's, what I need help with is applying the different numerical values to my formula based on the selection.

  50. Sorry mic-copied formulae I am using I have :

    =AND($P13="<100",$D13<TODAY())

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 :)