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 35. Total comments: 1726

  1. hye, I want to ask about how to highlight green for passed and red for failed based on another cell result? mind if you can show me the way? thankyou

    1. Hi Husna,

      Simply select the column(s) you want to highlight and create a rule with the formula that references another cells. For example:

      Green: =$A2="passed"
      Red: =$A2="failed"

  2. Hi Svetlana

    I would like to highlight cells in a column where the corresponding cells in an adjacent row return a formula error (#N/A). Can this be done with conditional formatting?

    Thank you.
    Ruth

    1. Hi Ruth,

      You can create a rule with a formula similar to =ISNA($A2) where A2 is first row with data in the column that contains #N/A errors.

  3. Hi !
    How can I creat a conditional formating with a formula I have in a cell of another sheet of the same document? or How can I use the same formula that for conditional formating in another part of the document?

    Thank you
    Mary

  4. Dear Madam,

    I am preparing a attendance sheet but I have some confusion with this sheet because I want if a personnel make holiday at Saturday and Monday to I can acquire 3 absent but I design sheet with A for absent and P for Present to that is why I have to face problem I am continuously thinking and applying but still I am unable to get rid of this hindrance kindly help me out.

    many thanks.

  5. i have a sheet with a matrix of users and whether they have access to a security role (roles are columns, names are rows, values are Yes/No). I want to use conditional formatting to compare this to a matrix of classes and highlight where the user's roles differ from the class they are assigned to. is this possible? i tried using a vlookup formula in a rule, and it didn't seem to work. Any thoughts?

  6. i have a sheet with a matrix of users and whether they have access to a security role (roles are columns, names are rows, values are Yes/No). I want to use conditional formatting to compare this to a matrix of classes and highlight where the user's roles differ from the class they are assigned to. is this possible? i tried using a vlookup formula in a rule, and it didn't seem to work. Any thoughts?

  7. Sorry to bother you, but have been trying to get this to work for ages. I have what will eventually be a large table of data. Column A is a word and B to O are a mix of numbers and words.
    I need the following to make the cell in column A to be filled say, green if certain criteria are met, orange if others and red if others.
    I can't even get the green section to work. This is what I have so far:

    I highlight either A2 or B2 to O2 (it doesn't seem to matter what I highlight, nothing works)then enter this:
    =and(D2<20, E2<55, F2<50, G2=Low, h2=Nil, j2<15, k2<20, m2<100, 0270 for red, G2 = high for red etc.
    If it's impossible to have the other two colours working in conjunction that's fine, even having the green working will be a great help.

    Thanks in advance if you can get to it,
    regards Liz

  8. How to use text formula in conditional format

    ex:7/25/2015
    7/26/2015
    7/27/2015
    7/28/2015
    7/29/2015
    7/30/2015
    on the above date i want to highlight saturday and sunday by using text(a2,"dddd") with conditional foramt, pls helm me.

    Thank in advance
    Chandra shekhar

  9. Hello-

    I have read through all of the questions on this page and didn’t see this specific question asked. I would greatly appreciate your assistance!

    I have an excel worksheet- starting in column and row D6 (start date), E6 (End date), and F6 (Frequency). Across the rows at the top we have weeks starting in column and row G4, H4, I4, etc = (July 13, July 20, July 27), etc.

    My first conditional format- to color in the weeks where a communication was sent, worked. That formula was: =AND(G$4$D6) and it applied to: =$G$6:$AM$38

    This worked well for the rows with the frequency of daily or weekly. Where we are struggling with is conditionally formatting rows to fill cells with monthly repetition.

    Currently, the formula I have: =AND(G$4$D7) is for a specific row i.e. applies to: =$G$7:$AN$7 and this highlights the specific cell that corresponds to the week of the first date that the communication was sent out.

    My first question:

    1) How do I create a specific conditional formatting rule using the =AND(G$4$D7) formula that fills in a cell every 30 days or 1 month and also corresponds to the correct week, leaves the remainder of the cells blank for that row, and that also ends when the end date in column E says? Will I have to have 2 separate formulas for each row with a monthly frequency? One for filling in the cells, the other for shading the remainder blank? Also, I should be able to specify in one rule that the formula applies to row 7, 10, 15, 22 for example in the “Applies to” section without having to make a new rule for each row, correct?
    2) What is the order in the rules manager that these rules should be placed? Should the original formula for all cells be placed at the top or bottom?

    Thank you in advance for the help.

  10. Using conditional formatting to highlight calender dates.
    Currently if I receive a document on the 1st July, I have to contractually respond within 10 working days. I am using an Icon set to say Green when plenty of time changing to red 3 days before I have to reply.
    My problem is once I reply (the date is recorded in another column) I want the Traffic lights to disappear complete. HOW can I do this????

  11. Hi. I am struggling with trying to resolve the icon sets when the data is Zero. I string 7 months of data to compare month to month. I am using the reverse icon when we have a drop in a bad measure. Normally, there is a numerator and denominator. However, on the months where we have consecutive Zero numerators, the icons do not show and only show "0" which I cannot resolve to just be a neutral (no change/yellow arrow). Any suggestions?

  12. Having a prob with conditional format. I tried using the following formula:
    =((M15-K15)/K15)>10%
    If it is true then turn the cell to yellow.
    #1 It is not turning that cell to yellow.
    #2 If I copy the conditional formula to a cell on the SS to verify it shows as true so it is valid.
    #3 After I get the correct formula how is it applied to a column because right now it always wants to reference the same line.
    =((M15-K15)/K15)>10%

    Thanks!

  13. Hi Svetlana.

    I managed to SOLVE my problem.
    The trick was to format the cells with a partial border, i.e. leaving the left side blank. Now everything is fine and working.

    I wish you all the best.
    Enzo

  14. Hi There:
    I'm working on this project that I use the conditional formatting to change the color of the cell that is doing the calculations. Unfortunately they have changed the requirements and they want me to add another cell that will change its color when the other two cells change there's. for instance if Column A turns red and column B turn green then column C has to turn red. If A and B are both green then C will turn green(if one of the A or B is red then C will always be Red). When the column C turns red it has to display Fail and when Column C is green it has to display Pass. Can we make this in excel? Any feedback will be deeply appreciated.

  15. This site is great! I read through many of the comments and couldn't find anything like this, but it may have already been discussed. I have a column with cities and an adjacent column with states. There are different cities with the same name in several states- Springfield, for example. I want to highlight Springfield, MO in one color and Springfield, IL a different color. Can I create a conditional format that will say: when Cell Q="Springfield" and Cell R="MO", Cell Q should be green. Then if Cell Q = "Springfield" and Cell R= "IL", Cell Q should be blue. Thank you for your assistance!

    1. Hi Helen,

      Of course, you can create such a rule, e.g.
      Green: =AND($Q2="Springfield", $R2="MO")

      You can even list several cities in the first condition so that you won't have to create a separate rule for each city, e.g.

      Green: =AND(OR($Q2="Springfield", $Q2="city2", $Q2="city3"), $R2="MO")

      1. This is pretty close to the formula I was already using and I couldn't figure out why it wasn't working! I played around with it a little and after I changed from $Q2 and $R2 to $Q1 and $R1, it worked! Thank you for your help.

  16. Dear Svetlana,
    first of all let me congratulate you for this excellent blog.

    And now to my question:
    My worksheet is composed of 26 columns and 81 rows.
    Column A contains a list of items and column B their price; column Y the total number of items in stock and column Z the number of items to be put on sale.
    Row 1 is a heading.

    Cells C2:V2 contain numbers 1 to 20. Cells C3:V81 are empty and should be conditionally formatted, based on the following criteria:

    if the number above each cell (C2:V2) is less or equal to the corresponding value of cell Z of the cell's row then that cell must receive a border. Of course, the formatting should change when the value in column Z changes.

    I have already tried different methods that seem to work, at least partially (e.g. a formula such as =C$2<=$Z3). The problem is that when te values in Z decrease the borders don't disappear; instead the (now) empty cells keep a double-line vertical border. What am I doing wrong? Is it possible to end with a "clean" sheet without going for a macro?

    I hope you can answer me and in the meantime I thank you very much.
    Enzo

  17. Thanks a lot to you and Google aswell

  18. Thank you for a fantastic resource, I'm an inexperienced Excel user but your tutorials have really developed my skills. However, I'm struggling with conditional formatting.

    I have a worksheet which calculates gross margins. I'd like to be able to highlight rows where the margin falls below a set level. However the cells that hold the margin contain a formula (=IF(F2=0, "", F2-M2/F2) rather than a value. It is the result of this formula that is the margin.

    Please could you advise how I can make the formatting conditional on the result of the formula?

    1. Hi Helen,

      I'm glad to know our tutorials have proved helpful. In conditional formatting, it does not really matter if a cell contains a value typed manually or returned by some formula. So, you can create a rule based on a simple formula similar to this:
      =$C2<10

      Where C2 is the cell with your margin formula and 10 is a "set level".

      1. Hi, thanks for the speedy reply. I wondered if that was the case but I've not had any success.

        If I set it to =$N2<50 it highlights every row except those that are blank regardless of the value returned. This is why I thought that maybe it was different for formulas.

        1. Helen,

          It's very strange because the rule worked perfectly on my test sheet. Please make sure it applies to a range beginning in row 2, for example A2:N100.

          If the problem persists, you can send a sample workbook to our support team (support@ablebits.com) and we will try to figure it out.

          1. Helen,

            I'm posting the formula here just in case my message does not reach you for some reason. Because the Gross Profit column displays percentages, the conditional rule formula should be written for percentage as well. Once you change it to =$N2<50%, the rule will work perfectly.

  19. Hi Svetlana, Firstly well done on an excellent page and very helpful explanations. I recently came across an auditing spreadsheet where you had questions to answer and the option to select a colour/text from a drop down menu on each scoring cell, in this case Blue, Green Yellow and Red. The spreadsheet then added the number of e.g. RED cells and produced a score. I have not been able to determine how they did this because the spreadsheet was protected. If I have asked the question clearly enough, can you guide me please?

    1. Hi Laurie,

      Thanks so much for your kind words.Most likely the colored cells are counted with a macro, may be something like this one. Anyways, it's difficult to say anything with confidence without seeing the source data.

  20. Hello Svetlana,

    I have 2 columns, first (G) with the Status, validated list, Red, Amber, Green, Closed. On the second column (H), I have % of completion. On H I need to used Data Bars, but the colour needs to be the one described in G column. For Closed will be blue. Can you help me do it?

    Thank you,
    Marius

  21. hi,
    I want to put a statement in excel and want to add a specific value reference in between the statement as "today total sale is .........( reference of cell B15) and purchase is ....( REference of cell C51). is it possible if yes how????

    1. Hi Kawal,

      You don't need the conditional formatting for this task. You can use the CONCATENATE function or the & operator as follows:
      ="today total sale is "&B15
      =CONCATENATE("purchase is ", C51)

  22. Hi,
    I want to highlight cell which has specified value. Like if there are 1 to 10 nos. i want to highlight only 3, 2, 7. which formula do i use. Please help

  23. Great article but can't find exactly what I'm looking for.

    I want to make a formula that will look at a whole column, say the B column, in one sheet and see if there are any "No" entries. If there are ANY "No" entries, I want it to change the colour of a cell, say the A1 cell, in another sheet.

    I have a crude formula here, using a "TRUE" statement instead of colouring the cell and also giving the range 1-9999 which is ugly: =ISNUMBER(SEARCH("No",Sheet2!B1:B9999))=TRUE

    I hope this makes sense and would be really grateful of any response!

    1. Hi Johnny,

      I think you can create a rule with a formula similar to this:
      =COUNTIF(Sheet2!B:B, "no")>0

      1. Aha! Perfect! Thank you ever so much

  24. I've been working on a sales target spreadsheet that has normal formulas & then also using conditional formatting.

    In one part of the spreadsheet we are calculating the variance between 2 cells, ie E14-F14 this formula is in cell G14 (figures are 4-4=0). My conditional formatting for all the cells is
    =AND(COUNT(B6),B6>=0) set so if the variance is positive the cell will be green
    =AND(COUNT(B6),B6<0) set so if the variance is negative the cell will be red

    now this conditional formatting making cell G14 red, when we want it to be green. This happening for the cells in column G that have the same formula.
    However in all the other columns D, J, M etc if the cell is 1-1=0 the cell will be colored green.

    I have removed all the conditional formatting from the excel and inputted again & this hasn't fixed it. I'm not sure what to do next to try & fix this.

    I hope this all makes sense & look forward to a response!

  25. Thank you so much :)

  26. I needed conditional formatting for an excel sheet with growth chart. In this i wanna know which have growth and which have de-growth based on last year sales

  27. Hello! Thanks for the info above.

    Please can you help... I am looking for cell A to look at cell B and for cell A to change colour if the value is...
    Green - less than 10 of the value of B
    Amber - less than 5 of the value of B
    Red - equal to or greater than the value of B.

    The problem being that both B and A will change with data input and B. Hope that makes sense! Thanks in advance for your help.

  28. Hi
    I wondered if you could help me please. I am trying to create a month by month summary of our customer service scores. All i would like to do is to highlight the cell green or red based on whether the score has increased or decreased from the previous month. For exmaple:
    Month Overall
    Oct-14 -100
    Nov-14 18
    Dec-14 -50
    Jan-15 -8
    Feb-15 45
    Mar-15 -2
    Apr-15 30
    May-15 20

    So i would like May's score to be highlighted red because it decreased from April. But April to be highlighted green because it increased from march.

    Thanks

  29. J M K S
    3 2 3 5---------k--?
    76 5 75 7---------k--?
    4 564 76 53--------j--?
    354 34 456 24--------s--?

  30. Hello,
    i have a small dilemma and would appreciate if anyone could help out.

    So i have the following arrangement

    J M K S
    3 2 3 5 k ?
    76 5 75 7 k ?
    4 564 76 53 j ?
    354 34 456 24 s ?

    Were I would like the letters column to be matched to the letters row, and the question marks replaced by the corresponding value under the letters row.
    resulting for example in the following
    k 3
    k 76
    j 4
    s 24

    does anyone know what equation I need to use to substitute the values instead of the question marks?

    Thank you

  31. I have the traffic light icon working in the cell that has the value, however I want the value to be in one cell the the traffic light to be in the next cell. Is that possible?

    1. Hello Caren,

      Because it is not possible to use relative references in conditional formatting criteria for icon sets, you cannot apply icons based on another cell's value.

      As a workaround, you can copy the values to the next column, say by entering a simple formula like =$A1 in cell B1 and then copying it down to other cells in column B. Then you apply icons to column B and select the "Show Icon Only" option. So, visually you will have values in column A and corresponding icons will display in column B.

  32. Hi svetlana,
    Is there a way to colour a cell with two colours depending on a values cells in other work sheet?

    ex: sheet 1 cell A1 to be colored with red, if value in sheet 2 cell A1>0 and also sheet 1 cell A1 to be colored with green, if value in sheet 2 cell B1>0

    1. Hi Thushan,

      Of course, it's possible. In conditional formatting formulas you can refer to other sheets just as you would normally do. For example, you can create 2 different rules for A1 in sheet 1:

      Red: =Sheet2!$A1>0
      Green: =Sheet2!$B1>0

  33. Is there a way to conditionally format cells to match the fill color of an original cell with matching text that was manually color filled?

  34. Hi Svetlana.
    I have a conditional format running that changes a cell blue if the letters GI are entered or red if the letters AFM are entered, I also need the cell to the left of GI or AFM cell to format blue or red. I have tried many formulas but without any luck

    1. Hi Garry,

      Just apply the same rules to two columns instead of one.

  35. Hi Svetlana!

    I'm copying exact version of your formula: =AND($B2>5, $B20 but when using "AND" function and trying to make multiple criterias it just keep giving error.

    Wbr

    1. Hi Suva,

      Please post the entire formula you are using and we will try to figure out the root of the problem.

  36. I have several series of data validation dropdowns, and lets say when E5 = text_value i want G5 to be highlighted

    because under specific conditions (depending on what previous choices are made) there needs to be an additional dropdown. i am not concerned with making a conditional data validation (probably not possible anyway) but i was hoping someone could help so that i could just highlight it so it sticks out when additional information is required

    1. nevermind!! i got it! after reading other situations i realized that the rule would be specific to the selected cell and wouldnt necessarily be a general formula for the entire sheet

  37. Hi guys, can someone help me please..

    How To use conditional formatting for example... in cell A1 Sheet 1, based on the value from cell A2 in Sheet 2.

    So...
    If Cell A2 (Sheet2) = "DA"....then Cell A1 (Sheet1) background is RED.

    Thank You

    1. Hi Ivan,

      Create a rule for cell A1 Sheet 1 with the following formula:
      =Sheet2!$A2="DA"

  38. So I have this data on a summary sheet:

    #INT1 #INT1 #INT2 #INT2 #INT3 #INT3
    $DAT Y $FILB Y $DAT Y
    $FIL-B Y $FIL-H Y $FIL-B Y
    $FIL-H Y $FIL-POS Y $FIL-H Y
    $FIL-POS Y $N/A-FIL YYYYYYNN $FIL-POS Y
    $N/A-FIL YYYYYYNN $SEC-M NNNYYNNN $N/A-FIL YYYYYYNN
    $ORD-FIL YYYYNNNN BACF NNNYNNNN $ORD-FIL NNNYNNNN
    $SEC-M NNNYYNNN BARS YYNYNNNN $SEC-M NNNYYNNN
    $SEC-USR NNNYNNNN BATS NNNYNNNN $STATS Y
    $STATS Y BBDS YNNYNNNN AONE NNNYNNNN
    AONE YYNYNNNN BBIF NNNYNNNN AORD YYYYNNNN
    AORD YYYYNNNN BCAT NNNYNNNN ASEC NNNYNNNN

    And so on…

    I was wondering if there was a way I could check row A and B against all other rows for pairs of data like $DAT and Y would be what to check for so $DAT and Y would be highlighted in A,B and E, F and the whole sheet.

    Any help would be greatly appreciated. Thank you. I can send a sample spreadsheet if you need.

  39. Does anyone know how to make a conditional format to create a specific number based on another cells number?
    Example:
    Cell 1 shows the number 3
    I need cell 2 to then show the number 1.

    All in increments of 3, if it shows 6 then it will show 2.
    9 = 3
    12 = 4 etc. Also, If it is between 3 and 5 it will still show a 1, between 6 and 8 it will still show a 2 and so on.
    Any help would on this conditional formatting would be appreciated.

    1. Hi Shawn,
      I believe a Lookup Formula would be your best option.

      If you have your data starting in cell A2, you can add the following formula in cell B2:

      =LOOKUP(lookup_value, lookup_vector, [result_vector])
      =LOOKUP(A2,{3,6,9,12},{"1","2","3","4"})

      You can keep expanding the formula by increments of 3, but make sure you update the lookup_vector and result_vector.

      I hope this helps.

  40. Hi

    If anyone can suggest a reason for the following problem i'd be grateful.

    I am using conditional formatting to colour code times and distances for track and field according to a set of standards.

    For example I have formatted columns A, B, C, D so that

    2.5 to 3 are red
    3.1 to 4.49 are yellow
    4.5 and greater are green.

    I want to format other columns to use the same colour system but for different parameters as they are to represent different events.

    I have tried copy and paste as well as format painter to save time and then edit the rules only, removing the need to select the formatting each time.

    However, when I highlight a selection and edit the rule (checking that current selection is correct) it applies the rule change to the entire sheet!!

    Why does this happen?

    Yours

    Matt

  41. I want to count payments: 1 of 30, 2 of 30 by writing 1/30, 2/30 and so on. I want to write two cells and drag to create the rest (as I do with dates or numgers).
    Can you suggest a way to do this? Thank you in advance

  42. Hi,

    i am working on shift roster excel and i want to highlight only shift person name cell who is today.
    e.g.
    row A1 has Date
    column A2 has shift person name
    and B2-z2 has shift name(Day,Night)

    formula has to first check today's date then search in that column the shift name(day,night) if match Day the highlight the shift person name which is in column A2.

  43. Hi,

    Great forum, hopefully what i'm trying to do is possible. Is it possible to inherit the color from referenced cells. For example, if I had a formula: =concatenate("This is a test ",B2). I need to inherit the existing value and color in cell B2.

  44. Hi there,

    I got set of data and I need to color the cell based on value row before it.
    Ex.

    A B C D
    a 2 1 3 4
    b 3 0 4 5
    c 1 3 5 7
    d 8 9 3 3

    I need to color the Ab red (>Aa) and Bb green (<Ba). I want to apply the rules to all row and column. Is there anyway i can do it?

  45. Hi,

    I have been trying to do cell formatting for following condition:

    =$Q3$AS3

    I want to highlight the cells of column Q3 if the value doesn't match with values in column AS.
    I used above mentioned condition but somehow it's highlighting all the rows and columns from Q until AS. I tried to select following ranges "Q3:Q100" as well as "Q3:AS3, Q100:AS100", but no use.

    Please suggest.

    Thanks,
    Shipra

    1. Hi Shipra,

      I have just created a rule for Q3:Q100 with the following formula and it highlighted only cells in column Q that are not equal to values in column AS in the same row:
      =$Q3<>$AS3

      Please double check the applied range via Conditional Formatting > Manage Rules.

  46. Hey there,

    I'm trying to set a conditional format where I want to change the colour of column A if the column width does not equal "10.29".

    Would you be able to help out?

    Thanks,

    Jon

    1. Hey Jon,

      I have been trying to attempt the same thing with cell formulas. I have put in =cell("WIDTH") but it does not show the exact amount. Let me know if you have any luck with finding a formula.

      Matt

  47. Hi Svetlana,

    First of all Congratulations for your blog! I find it 'state of the art' and a precious on-line resource. Of course I will spread the word about it...!

    As I wasn't able to find a solution that works among the tutorials and examples you posted above, please allow to present my question:

    How to apply conditional formatting to columns F, G, H and I (by instance change font colour to 'red'...) when it met a given criteria (comprised of the word string IMP) in the same line in column A (in Microsoft Excel 2007)...? Or in another way, which formula to use...?

    I deeply appreciate your help. Thank you.

    Kind regards,

    Carlos

    1. Hello Carlos,

      Thank you very much for your kind words.

      You can select the entire columns $F:$I and create a rule with the following formula:
      =$A1="IMP"

      The above formula works for the exact match. In case you are looking for a partial match formula, i.e. highlight columns F:I if column A contains values like "IMP 2" or "xIMP", then use the SEARCH function as follows:
      =SEARCH("IMP", $A1)>0

  48. Hi Tom,

    Assuming that row 2 is your first row with data, select all the cells in column B you want to color beginning with cell B2 and create a rule with the following formula:

    =AND($A2="requested",TODAY()-$B2>14)

  49. I'm having a problem with changing a cell colour based on multiple cell values.

    Example

    Column A has 3 values using a data validation list "requested, booked and delivered"

    Column B has the date of request.

    I would like the cell in column B to change colour if Column a value is "requested" and if date in column B is over 14 days old.

    Any help would be really appreciated

  50. Im doing a data bar formatting for a cell, and I would like the color of the data bar to change relative to the value of another cell.

    1. Hi Luis,

      Select the cells where you want data bars to appear, click Conditional formatting > Data bars > More rules. In the "New Formatting Rule" window, select Formula in the "Type" box and enter your formula in the "Value" box. Just keep in mind that relative cell references are not allowed in Data bar formulas.

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