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

  1. Conditional Formatting Problem: I have made 8 Rules to color code certain words. 6 of the 8 Rules work great, but 2 do not. I have deleted the 2 Rules & reentered, but still no luck. HELP!

  2. PLEASE FIND THE REQUIREMENT BELOW TO WRITE A FORMULA IN EXCEL,
    IF THE AGE IS BETWEEN 1-35, PRINT 1000,
    IF THE AGE IS BETWEEN 36-40, PRINT 2000,
    IF THE AGE IS BETWEEN 41-45, PRINT 3000,
    IF THE AGE IS BETWEEN 46-50, PRINT 4000

    1. Cell L18 Cell L19
      AGE VALUE
      1 - 35 1000
      36 - 40 2000
      41 - 45 3000
      46 - 50 4000

      =IF(L18<36,"1000",IF(L18<41,"2000",IF(L18<46,"3000",IF(L18<51,"4000",""))))

      1. Arif:
        I think you are looking for something like this:
        =IF(B55<=35,1000,IF(B55<=40,2000,IF(B55<=45,3000,IF(B55<=50,4000,"Out of Range"))))
        Where the value being tested is in B55.
        The "Out of Range" is needed to supply a display message if the value is above 50.

  3. i hava two coloum in excel sheet A and B.
    the value is different in both coloum.
    i need a conditional formatting formula to change color of col B when col A value is lower then col B.
    Single cell color change but when i select the coloum it is not working
    please help..........

    thank you.

  4. How can I use conditional formatting in a single column?
    For instance, using column A entering text in A1, then when text is entered in A2 and hit enter, A1 will have a strikethrough and A2 will not. Enter text in A3, A2 will strikethrough and A3 will not, so on and so forth.

    I appreciate any help.

  5. I have an Excel workbook with two sheets. I need to make column D in Sheet 2 format to fill the background a color if Sheet 1 has the exact same number in Column C. What is the function I type into Conditional Formatting New Rule on Sheet 2? Please and thank you!

  6. Hello, Svetlana

    I'm having some problems using "OR" function. What I need is something like this:

    =OR($D1 = "TEXT 1" , SEARCH("TEXT 2",$D1) > 0)

    "Translating" what I'm trying to do is "I want TRUE when either the D column has the exact value 'TEXT 1' or has 'TEXT 2' written with not necessarily exact match"

    The problem I'm facing here is that if I add the SEARCH function, it only matches the result of the SEARCH function. If I remove it, it matches the "TEXT 1" one.

    Am I missing something here? I'm a programmer and have to say Excel functions have a really terrible syntax. I'm sure it is a very simple issue, but I can't solve it.

    Thanks in advance

  7. Hi,

    I Have a question regarding conditional formatting. I know how to apply a rule that if the value is under a certain amount, the cell value will equal this amount. I now want to apply a rule that if a cell is between a range, the value s equal to a certain formula. Example; if value is between 10000 and 20000, the result is 10000 plus 90% of the portion in excess to 10000.

    Help?

  8. hello
    please I want the A1 and B1 to automatically give me an answer in cell C1
    A1 20 + B1 20 = C1 40
    please how do I format the cells
    I really need your help

    1. Emmanuel:
      If I understand your question you need to enter this formula in C1:
      =A1+B1

  9. Hi
    I have been trying to use AND formula in conditional formatting to change color of cell according to values but its not working.
    i need to change the color of the cell depending on the change in the value of the cell (eg. difference between A2 and B2 should be highlighted in yellow if the difference is between 0 to 2.99%. if its more than 3% difference it should be highlighted in red.) can you please help me out in this

  10. Hi,

    I am have an excel budget sheet with three important rows at the bottom.

    1. a sum of each column.

    2. a row with the copied value of the sum-value above to hava as a control.

    3. a formula that subtract the above values (I would like this value to be zero as a control).

    To the first and third row I would like to have conditional formatting, coloring them red if they are not the right value (i.e: the 1st row to colour red if its not the same as thr 2nd row, and the 3rd row to colour red if its not zero).

    This contitional formatting only applied correct to three of my columns, and three colours red even if the values are correct.

    Please help!! Going nuts here :) Thanks!

  11. In the,
    ****Excel formulas to work with text value****
    section,

    I found,
    >0 selects a string containing and beginning with the specified word.

    Whereas, >1 selects the string only containing and not beginning with the specified word.

    Correct me if I misunderstood something.

  12. Hello,
    I was hoping you can help create a formula/condition rule. I need an entire column “O” to return a value based off a digit I put in it a cell IN COLULMN O.
    For example:
    If I type 1 in O5 I want O5 to return a value of 1.08
    If I type 60 in O50 I want O50 to return a value of 65

    Similarly in column Q- If I type “Y” in the cell, I want the cell to return a value of 65. For this I set a condition rule =If(Q1:Q25=“Y”,65,0) to be applied over Q1:Q25. Needless to say- it didn’t work!

    Can you help me please???

  13. Hello,
    I was hoping you can help create a formula/condition rule. I need an entire column “O” to return a value based off a digit I put in it a cell IN COLULMN O.
    For example:
    If I type 1 in O5 I want O5 to return a value of 1.08
    If I type 60 in O50 I want O50 to return a value of 65

    Similarly in column Q- If I type “Y” in the cell, I want the cell to return a value of 65. For this I set a condition rule =If(Q1:Q25=“Y”,65,0) to be applied over Q1:Q25. Needless to say- it didn’t work!

  14. Hello

    I am trying to find a formula to find the greater value between two dates. between two columns in the same cell. I know I can use conditional formatting>Highlight Cells rule>Greater Than, however I am trying to do this on a spreadsheet with over 1000 lines. is there any way I can use a formula to help me to this in one go without having to do the above line by line

    thank you

    1. David:
      You don't have to apply conditional formatting line by line. You can select all the cells that hold the calculation that you need formatted and apply the formatting to them all at once. The conditional formatting rule is the formula.
      You can select all the cells in the column by clicking the column heading.

  15. Hello,
    I have two sheets in excel 2007, where I enter via barcode scanner serial numbers of devices, one sheet is for direct sales and the other sheet is for credit sales.
    I need a way to validate for duplicate s/n between two sheets. At this moment I am using the formula =COUNTIF(sheet1!d5:sj30000), like conditional formatting highlighting the duplicated cell. The system find duplicates very good, but becomes very, very slow.
    Now I want to validate at specific time, for example in the night, when the system is not used.
    Can you help me to setup time driven validation formula to trigger at specific time.
    Thank you very much for your time.

  16. I am looking for help on creating a conditional format where I am color coding a row based on a # the user inputs. These color codes (1 - 6) are used to indicate the order is in a particular status as they determine.

    Some cells on the row will already be highlighted in vbLavender. These are set by a different process to indicate something has changed with this data. I don't want the conditional formatting to cover this.

    So for example cell BB44 has the lavender background.

    Currently this is my VB code for the conditional formatting for color 5:

    Selection.FormatConditions(1).StopIfTrue = False
    Range("A2:BW99999").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$BT2 = 5"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
    .ThemeColor = xlThemeColorAccent1
    .TintAndShade = 0.399914548173467
    End With

    So if in cell BT44 I enter a 5 the row is shaded blue.
    This also shades BB44 as blue. If I delete the 5 the lavender color is still there. How would I change the above to not color cells that have an existing color or vbLavender?

    Any suggestions would be greatly appreciated :-)

    1. John:
      VBA help is beyond the scope of this blog, but there are many sites where you can find VBA help. Just Google "VBA Format Conditions" and you will find them.

  17. I have some formatting set up so, if for example,I have cell B8 highlighted green with the letter "w" in it, any cell I put a W in will turn green as well. Where I am stuck is how do I get an adjacent cell to turn that same color without putting a "w" in it. For example. if I put a "w" in cell D8 and it turns green, how do I get cell D9 to turn green based on D8's value while leaving cell D8 blank?

    Thanks!

    1. Todd:
      I think this will work. Select D9 then Conditional Formatting then New Rule then Use a formula to determine which cells to format then in the formula field enter =D8="W" then select the green formatting you'd like to see.

  18. I really appreciate you posting this tutorial Svetlana. It has made my work (and others here) a lot easier, keep up the great work! I will consider subscribing to Ablebits, you guys rock!

  19. hi
    i want to create a conditional formatting for following
    Column 1 Contains Date of shipment
    Column 2 Contains contains a (tick) which confirm if the shipment is sailed.

    Column 1 should turn red when Shipment date occurs
    and Column 1 thr should be no formate if Column 2 contains a Tick

    Please help

  20. hi everyone,
    i want to create conditional formatting for the following:
    Column 1 contains due date
    Column 2 contains actual date
    Column 3 would contain conditional formatting if Column 1 > Column 2
    please help
    Thanks in advance

  21. 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.

  22. 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!

  23. 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.

  24. 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?

  25. 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?

  26. 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!

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

  28. 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

  29. 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

  30. 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

  31. 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.

  32. 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.

  33. 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=""

  34. 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!

  35. 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.

  36. 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"?

  37. 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()

  38. 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.

  39. 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.

  40. 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.

  41. 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

  42. 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.

  43. 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

  44. 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 "/"...

  45. 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

  46. 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

  47. 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!

  48. 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

  49. 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

  50. 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?

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