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

  1. Hi dear
    Can I highlight a whole record means specific row upto a specified number of columns.
    Scenario:
    If the student successfully completes his course then I want his entire record(row) to be highlighted as green when the end date column equals to today.
    Thanks in advance

  2. Hi dear,
    I want col H to be red fill as well as showing the text Defaulter
    1)if col E(completion date of course) is passed and the col F (remaining fee) is still to be paid i.e >0
    2) if col E(completion date) is passed and the col F=0 then I want green fill and showing text Clear
    3) if Cole E(completion date) is not over which means the course still is in progress and col F>0 then I want orange file showing text "Ask for the Fee".
    Any help will be highly appreciated
    Thanks in advance

    1. Can any1 like to add?

      1. I finally got my answer by reading your if & and/or topic and now want little bit more complexity in it.

        =IF(AND(E70),"Defaulter",IF(AND(E7TODAY(),Q7>0),"Ask for fee","")))

        Thanks

  3. Hi,
    I want to highlight a cell containing a alphanumeric based on multiple references
    Ex:If any cell contains BMR01 or BMR02 and goes on it has to get highlighted.

    Tnks in advance

    1. tell me how to take multiple references

      1. Hello Rajesh!
        It depends on what rules are used to create an alpha numeric code.
        For example, you can fulfill your task using the following formula in a conditional formatting rule:
        =AND(LEFT(A1,4)="BMR0",IFERROR(VALUE(MID(A1,5,1)) < 3,FALSE))

  4. Hello, i would like to change the colour of a number of cells in a row if column P contains any text, however the colour it changes to depends on the text in column D would you please be able to help
    many thanks.

    1. Hello Charlotte!
      You need to create different rules: one for each colour and text condition. For example:
      yellow color - =AND(NOT(ISBLANK(P1)),D1="text1");
      orange color - =AND(NOT(ISBLANK(P1)),D1="text2") etc.

  5. Hi. My dates are customised as ddd dd mmm yy (so today is Tue 15 Mar 16). I can't get CF to turn today red using today(), even though Excel knows that the cell is actually 15/03/2016. Can I do this another way?

    1. Hello SeeBee!
      Please select the entire column (for example D) and create a conditional formatting rule using the following formula: =D1=TODAY()

  6. How to format a range of cell bases on a list of values (range of values). Ex. I have a lis of available answers: A, B, C, D ..., Z. So, whenever a user writes an answer not part of the list, the cell is formatted into red color (for ex).
    I tried to use the formula: =$C2AcceptedValues
    where AcceptedValues is the range name of the accepted values. But for whatever reason it's not working. Any suggestions? What do I do wrong? Thanks.

    1. =$C2AcceptedValues ($C2 not equal to AcceptedValues)

  7. how to Rectify Circular reference error

  8. I use conditional formatting to change the color of the cell from green for good to red for bad, works good. My boss just asked me to modify this to put the conditional formatted color into another cell. So what he wants will look like this, cell A5 has conditional formatting that will turn green or red depending on the text value and on the same page cell AW83 will turn the same color as cell A5. I need help with the last part cell AW83 working

    1. forgot to mention cell AW83 has a numeric value that needs to remain after the cell changes color thanks

      1. Hello Mike,

        The easiest way to go would be creating the same rules for AW83 that you have for cell A5.

        Otherwise you will need to add a user-defined function to your file as there is no function in Excel that checks colors. The following blog post describes the steps to get our GetCellColor function:
        https://www.ablebits.com/office-addins-blog/count-sum-by-color-excel/#count-cells-color

        You need to copy just the first function from the code in the post.

        Then you can use this function to get the color code from A5 in another cell, e.g. enter =GetCellColor(A5). Finally, you'll need to create a conditional formatting rule for AW83 and use the following type of formula in it:
        =GetCellColor($A$5)=5287936

        5287936 is the color code you need to replace with the code of green or red color you may have in A5.

  9. Hello,

    If the cells in the column have negative and positive value (ex. A1 = -1, A2 = 9), how can I create a formula to fill cell with red color if negative value and green if positive value?

    Thanks,

    1. Hello Tim,

      You need to create two conditional formatting rules: one for each color.

      You can use this simple formula for positive numbers to fill with green color:
      =$A1>=0
      Here is a formula for negative numbers with red fill format:
      =$A1<0

  10. Hello, I'm not sure if this is even possible with Excel.
    I want to change the colour of a cell based on whether another cell is SELECTED.

    E.g. If any cell in Row 1 is selected then cell A1 should turn grey.
    If any cell in Row 2 is selected then cell B1 should turn grey, etc

    Thanks

  11. Hello,

    I am trying to make cell, for example, A4, be filled blue if in cell I4 it says "RCT".

    I've managed to do this for single cells but selecting the cells in question. However I have attempted to apply this to the whole column so that any cell in column A turns blue if cell in columnn I of the the same row says "RCT", however I've been unsuccessful.

    The rule which I Have used says
    =$I$2:$I$49="RCT"

    which applies to
    =$A$2:$A$49

    Can anyone explain why this isn't working at all??

    Thanks a lot,

    Freya

    1. Hello Freya,

      Please select the entire column I and create a conditional formatting rule using the following formula:
      =$I2=$A2
      Excel will automatically change it to =$I3=$A3 for line 3, and so on.

  12. I have a spreadsheet that in one column (P) has a list of temporary badge numbers in it; then in column A I insert and assign one of the badge numbers from column P to a person. What I would like to have happen would be when I insert one of the badge numbers from column P in column A the corresponding badge number in column P would automatically highlight. That way I can tell at a glance which badge numbers have already been used and which have not. I have not been able to figure out how to get this to happen, your assistance would be appreciated. Thank you

    1. Hello Ceci,

      Please select column P and create a rule that uses a formula to highlight the cells:
      =Countif($1A$1:$A1000,$P1)>0

      Here P1 is the first selected cell, $1A$1:$A1000 is the range you use to assign the numbers.

  13. Hi, I have a spread sheet to calculate when major plant items are due for replacement (year purchased (2000) + expected life in years (10) = Year of disposal (2010), very basic (cells formatted as numbers). In a single cell I have the current financial year i.e. 2016 (number format), I would like to conditional format any year that is equal & prior too 2016 red, and any year greater than 2016 (i.e. 2017) green.

    1. Hello Dave,

      Please select the column with dates and create two rules that use formulas. One rule to highlight earlier years in red:
      =B2<=2016
      The second rule for highlighting later years in green:
      =B2>2016
      Here B2 is the first selected cell.

  14. Thank you for sharing. Is there a way to highlight my "b" column if my "a" column has a date past today's date (today())? thanks.

    1. Hi Yer,

      Try creating a rule for column B with this formula: =$A2>Today()

  15. Hi all, I have 2 columns each have a date. Column (1)being a test date and column (2) being a set date 7 days after the test date, for reoccurrence of the test. I need to format so that column (2) has to actions.

    1. it turns orange when it is 5ays from its next test.
    2. it turns red when it runs over the due date.

    any help would be appreciated.

    1. Hi Darren,

      If we understand your task correctly, you can do this by creating two conditional formatting rules:
      1) To color cells red when the date in column 2 is the current date or earlier:
      =$B2<=TODAY()
      2) To color cells orange when there are 5 days left to the test date:
      =AND($B2-TODAY()>0,$B2-TODAY()<=5)

  16. JANUARY 2016
    Week Sun Mon Tue Wed Thur Fri Sat
    1 2
    1 3 4 5 6 7 8 9
    2 10 11 12 13 14 15 16
    3 17 18 19 20 21 23 23
    4 24 25 26 27 28 29 30
    5 31
    I made this calendar manualy and I want to highlight the number date automatically and link to Friday, January 1, 2016 (=Today())on the other row. Can you please give an answer

    thanks

    ronald

    1. Hello Ronald,

      If your task is to highlight the current date, you can use the following formula in your conditional formatting rule:
      =IF(ISBLANK(B9),FALSE,DATE(YEAR(TODAY()),2,B9)=TODAY())

      This rule will work for February. You will need to change the month number for each month, e.g. replace "2" with "3" in the formula for March.

      As for linking it to January 1, could you please clarify your task? What way do you want to link the dates?

  17. Hi Svetlana, I have been wrestling with this problem for a while and I am completely stumped.

    I have a spreadsheet which uses a formula (=INDEX('TMA Tracking'!K:K,MATCH(HelpSheet!$D$5,'TMA Tracking'!A:A,0))), in order to pull data off other multiple sheets within the workbook and display all the data in one place on one page (based on a key field common to all spreadsheets).

    My issue is that sometimes there is a null value that the formula is trying to retrieve and, so for a date for example, it displays 1900-01-00. I would like to highlight the result, but the conditional formatting in the cell only looks at the INDEX formula and not the resultant data that it displays.

    How do I fix that? Thanks so much in advance!

    1. Hello Mark,

      Conditional formatting rules look at the values in the range. If there is no date, your formula returns number 0 (the number of days starting from 01/01/1900) that is displayed in the date format. If you are trying to find such dates in your range, please replace the date 1900-01-00 with 0 in your conditional formatting rule.

      If your task is different, please describe it in more detail and share the formula you use in your rule.

      We'll do our best to assist you.

  18. I have a row with 5 columns and each cell in the 5 columns have numbers in them. I have another column with serialized numbered rows (1-50) and want to color the cell's background only if a number in this column matches any of he 5 numbers in the row (described at the beginning of this problem). How to write the conditional rule(s)?

    Spa-see-ba

    1. Hello George,

      You can use the following formula with your conditional formatting rule:
      =IF(ISNA(MATCH(A3,B3:F3,0)),FALSE,TRUE)

      We hope this helps!

  19. How can I compare two e.g. a1:d1 with f1:i1 please need urgently

    1. Hello,

      If you are trying to find complete row matches, you can use our Duplicate Remover add-in:
      https://www.ablebits.com/excel-suite/find-remove-duplicates.php

      Click on the Compare Two Tables icon, select A1:D1 (or as many rows as needed) as your first table, and F1:I1 as your second table, choose the necessary key columns for comparison and the action for the results, e.g. you can highlight all matching rows in your main table.

  20. I am using conditional formatting quite extensively on a work plan template. I have set up for different sections to format according to about 7 or 8 exclusively alternate options.
    However, I don't understand why the applicable ranges for the formats seem to adjust themselves without prompt, splitting out across separate ranges. I have tried to remedy this by displaying the format list to show 'This sheet' and reducing each rule to just one appearance, so it shows one (comprehensive)range per rule. However, it soon changes itself again! I have tried playing around with the $s too and can't get it to stick.

    To add to that, I now have a problem that when you insert a row within one of the conditionally formatted ranges, it automatically adjusts the first choice format (no format for blanks). It changes it so that it no longer applies to any rows previous to, and including, the new one. So, where the format range might have been set as $F$1:$U$80, if you add a row at row 6, all of a sudden the first choice formula becomes $F$7:$U$80.

    Where am I going wrong??

    Many thanks.

    1. Hello Jo,

      Please try to convert your data to a table in Excel (Ctrl+T), it may help with different issues, such as when a range of data gets broken.

  21. Hi Svetlana,

    i am trying to do conditional formatting on multiple cells. For example, in row B i have 100 values, in row C i have another 100 values - i want to format the cells so that if the value in Row C is over the the value in Row B it will highlight green, and if the value is lower it will highlight in red. The problem i have is i can do this for individual cells but i've tried so many formulas and just can't seem to get it right for multiple cells.

    Please please help!

    Many thanks and kindest regards in advance

    Jamie

    1. Hi Jamie,

      Most likely you have absolute references in your conditional formatting rules. To compare values in each row, select the cells you want to format and add two rules with an absolute column and a relative row reference, e.g.
      =$C3>$B3

      You can find more information about the difference between relative and absolute cell references here:
      https://www.ablebits.com/office-addins-blog/relative-absolute-cell-references-excel-conditional-formatting/

    2. Hi, I am facing a similar issue as Jamie has stated. I need to check the values of cells in Row 2 and color code corresponding cells in Row 5. Individual formulas for each cell work, but I am unable to extend formatting collectively over a range.

      Please help.

      Best Regards
      Sreeram R

      1. Hi Sreeram,

        Similarly, please make sure you use absolute row references in your formulas, i.e. put a dollar sign before the row number so that it is not changed: C$5.

  22. Hi,

    Need help on excel, I would like to know if there any formula for the excel that if I click on a single cell the contents of that cell will reflect on the other cell but the same work sheet.

    Example:
    The format is

    Cell data
    A1 1
    A2 2
    A3 3
    A4 4

    if I click Cell A1, the data will reflect on
    E1 = 1, and if I click cell A2, the data will also reflect to E1 = 2, and so forth.... to which cell I click the data of that cell will still reflect on E1.

    Thank You

  23. I have data in 2 different sheets. I want to color the cell of sheet 1 which is not available in sheet 2.

    e.g. if sheet 1 contains
    Fruit-apple, mango, grapes
    Vegetable- cabbage,carrot,potato
    in sheet 2 it contains
    Fruit-apple, grapes
    Vegetable- cabbage,carrot

    then mango & potato should be colored out.

    Kindly suggest a way to solve this.

    1. Hello Dipun,

      You can use the following formula in your conditional formatting rule:
      =ISNA(MATCH(A2,Sheet2!A$2:A$5,0))

  24. I have a specific need:
    I need a Bar Chart where the colour of a Bar should change based on the text Value in particular column on the table
    For. Eg.
    Teh followign cell references:
    A1: Worktype A | B1: 30
    A2: Worktype B | B2: 40
    A3: Worktype C | B3: 60
    Should show up as WT A - Green Bar; WT B - Orange Bar and WT C - Red Bar
    Every time the Work Type repeats in the table, the bar should automatically be of the colour mentioned in the rule. Is this possible?

  25. I am trying to use a 3 color scale formatting rule where each row of data contains the low/medium/high standards that should drive the formatting rule. This type of formatting rule doesn't want a relative reference which forces all of the formatting rules to just the very first low/medium/high standard to set the color.

    Other web postings suggest highlighting the whole range that the formatting rule should be applied to and then change the cell references to relative from absolute. However, I can't get this to work, excel will not accept a cell reference that isn't absolute.

    1. Hello Tom,

      Unfortunately this is a limitation in Excel: you can't use relative references for 3-color scale formatting, icon sets, etc. You either need to create a rule for each line, or specify the start and end points of the range with absolute references.

  26. Hello,

    Maybe someone will be able to help me :) Thanks in advance!

    The thing is:
    I have a value in B5 and this value needs to be in the range "-1% of B3; +1% of B3" to be approved for use. Next problem, I have an empty raw between 3 and 5, that I cannot delete and still need to use the formatting (the same when I have two or three empty raws between values that need to be compared). If value between "-1% of B3; +1% of B3" then the B5 cell gets green.

    How can I make it that the formating take the good value to compare it with, and that it ignores empty cells but goes up to the cell where the first value is. This value will change in function of the previous B value.

    Is that clear?

    Thank you for your help!

    1. Hello John,

      You need to create a conditional formatting rule with the following formula:
      =ABS(B5)<=ABS(B3/100)

  27. Cannot get this working and am going mad. I've tried all three combos (i.e. $E26, E$26, $E$26 but none works.

    Across columns E to M, I want to white out cell(row 27) if cell(row 26) is blank.

    So I'm using:
    Formula: =$E26="" Applies to: $E$27:$M$27
    or
    Formula: =E$26="" Applies to: $E$27:$M$27

    but neither works. Any/all help would be apreciated. Thanks!

  28. Very informative article. However, I am still stuck. I have tried several formulas but I can't seem to get my spreadsheet to corporate with me.

    I am trying to do a conditional formatting formula for the following situation: if C1>1 and A1>10 the C1 text will turn red.

    Hope you can help me:)

    Thank you,
    Heather

    1. Hello Heather,

      You can use the following formula to combine both conditions in your rule:
      =AND($A1>10,$C1>1)

  29. Is it possible to use conditional format the Text Value of a formula result into two different colors?

    eg., if the formula of a cell result is ="GBPUSD", possile to format the "GBP" to Red color and "USD" to Blue color?

    1. Hello Ian,

      This is not possible, conditional formatting rules are applied to the selected cells, you can't apply them to values at the moment.

  30. This information was exactly what I needed.

    I needed to highlight two columns (Date and Days) if the Days value was < 9 and the Days value is NOT BLANK.

    Column E contains a Cutoff Date.
    Column F contains the difference in days between Today's date and the Cutoff date: =DATEDIF(TODAY(),E2,"D")

    1) Format the Cutoff Date (column E) if it is Styles > Conditional Formatting
    - New Rule > Use a formula to determine which cells to format
    - Rule: =AND(ISBLANK(F2)=FALSE, F2<9)
    -- Applies the rule if column F is NOT BLANK and is < 9

    2) Format the Days (column F) if it is < 9 days and is NOT BLANK; highlight the value in RED.
    - Applied the same Conditional Formatting as #1 above.

    It worked perfectly! Thank you for the great details.

    1. Correction to my initial comment...

      1) Format the Cutoff Date (column E) if it is Conditional Formatting
      - New Rule > Use a formula to determine which cells to format
      - Rule: =AND(ISBLANK(F2)=FALSE, F2<9)
      -- Applies the rule if column F is NOT BLANK and is < 9

      2) Format the Days (column F) if it is < 9 days and is NOT BLANK; highlight the value in RED.
      - Applied the same Conditional Formatting as #1 above.

  31. Hi,

    I'm trying to get a conditional formatting to work;

    =AND($C2='Calculation Sheet'!$C$32,$AF2<='Template Master'!$D$32)

    C2 is a cell that will change between values [R, 1, 2, 3, 4, 5, 6]
    and
    'Calculation Sheet'!$C$32 currently equals the value "1"

    $AF2 value is currently 5
    and
    'Template Master'!$D$32) value is currently 13

    I would like AF2 to change colour if both conditions are met;

    When C2 and 'Calculation Sheet'!$C$32 equal the same value "1"

    and

    The value entered into AF2 is less than or equal to 13

    Any help would be great!

    Thanks.

    Ben

    1. Hi Ben,

      Your formula looks correct and it works with the conditions you listed. Could you please specify if you don't get the expected results?

  32. You are the best I have seen so far. My question is, When columb "D" decreases, I would like columb "E" to reflect the date that it decreased. How would I do that? Thank you.

    1. Hi David,

      Thank you for your kind words. Regrettably it is not possible to reflect the data change by using conditional formatting. You can create a rule for column D being equal to some value, less than or greater than a certain value, but not for the value increase or decrease.

  33. Hi,

    I've been searching for ages to get an answer to the following and being a complete novice at excel not having much luck in getting a resolve. Any idea how I can do the following:
    I have a s/s with columns of dates and then rows of chargeable and non-chargeble. In the table data I have hours. I need to highlight any non-chargeable work over 0 in red and then any chargeable work over 30 in blue. Can I do this in 1 go by conditional formatting? Please help :)

    1. Hi Keira,
      According to your description, it is possible. If you can send us your sample workbook to support2ablebits.com, we will try to help you.

      1. Thanks Alex. Is there an email address for the support2ablebits? Thanks again for looking at this.

  34. Hi,
    When using Conditional Formatting:
    In cell U2, I would like to populate a formula in the cell if K2 says "Income"
    I've tried different ways and I can't get it to work. Help?!
    A

    1. Hello ajensen,

      Conditional formatting changes a cell's format, but it cannot change the contents of a cell. Probably, it makes sense to enter the following formula in U2:
      =IF(K2="Income",YOURFORMULA,"")

  35. Hello,
    I have the following formula and it keeps producing following error: "#NAME"

    =IF(OR(F6=YES, G6=YES, H6=YES), "At Store","Not at Store")

    What am I doing wrong? The same formula works if i replace "YES" with "10 or 20 or 30".

    Thank you so much.

    1. Hi Sarah,

      All text in a formula should be enclosed in double quote marks. Your formula needs to read as follows:

      =IF(OR(F6="YES", G6="YES", H6="YES"), "At Store","Not at Store")

      1. Thank you so much. This is great!!!!

        As a follow up here is my major issue. How do I add this formula to an if, iserror, index formula? I keep getting an error.

        Working Formula:
        =IF(ISERROR(INDEX($B$2:$C$41,SMALL(IF($B$2:$B$41=E3,ROW($B$2:$B$41)),COLUMN($A$2:$A$501)),2)),"",INDEX($B$2:$C$41,SMALL(IF($B$2:$B$41=E3,ROW($B$2:$B$41)),COLUMN($A$2:

        Non-Working Formula:
        =IF(OR(F3="Yes", G3="Yes", H3="Yes"), "Available", "Not Available", ISERROR(INDEX($B$2:$C$41,SMALL(IF($B$2:$B$41=E3,ROW($B$2:$B$41)),COLUMN($B$2:$B$5000)),2)),"",INDEX($B$2:$C$41,SMALL(IF($B$2:$B$41=E3,ROW($B$2:$B$41)),COLUMN($B$2:$B$5000)),2)))

        Am I adding to incorrect location?

  36. ok,

    i was hopping i would find the answer on the page but i haven't so her goes...
    what i want is for example in b7= if(b6>b5)=a3 however if (b6<b5)=a2
    i cannot figure out how to do this, it needs to be that if the value of cell b6 is greater than cell b5 i get the result as cell a3 however ig cell b6 is less than cell b5 the result is cell a2. how do i do this? (keeping a running tally on a competition and want cell b7 to prepopulate for the winner on any given day)

    1. Hi Shantal,

      You don't need conditional formatting for this. Simply enter the following formula in B7:

      =IF(B6>B5, A3, IF(B6<B5, A2, ""))

      Please keep in mind that if B6=B5, the formula will return an empty string (blank cell).

  37. Hi Svetlana,

    I need to conditional format cells based on a changing value.

    B20 contains a percentage that changes each day (30%, 35%, 40%, etc).
    I want cells G23:G37 to conditional format if they are equal to value in B20, within 5% of B20, above B20, and below B20.

    Do I need a separate rule for each set of criteria I have or can I combine into one formula line?

    1. Hi Dillon,

      You will need a separate rule for each criteria because you would want to use different colors, right?

      And you can create the rules based on the following formulas:

      Equal to value in B20: =$G23=$B$20

      Within 5% of B20: =ABS(($G23-$B$20)/$B$20)>5%

      Above B20:=$G23>$B$20

      Below B20:=$G23<$B$20

  38. Hi,

    I want to get greatest value among two cells to be in new cell how do I do that.

    Regards,
    Ahmed

    1. Hi Ahmed,

      You can use a formula similar to this:
      =MAX(A1,A2)

      1. Thanks a lot.

  39. Hi
    I am having a hard time getting some conditional formatting to work, maybe you can help..??
    I have a spreadsheet with columns of data
    What I want to do is apply a rule to a column that will highlight the cell of a manually entered figure orange, and leave the cells that contain a formula with an unaltered format.
    thanks in advance
    :-)!

    1. Hi Rick,

      To leave the cells with formula blank, create a rule with the ISFORMULA function (no background or fill color is selected for this rule) and make sure it comes first in the list of rules, e.g. =ISFORMULA($A1)

      To highlight the numbers entered manually with orange, you can create a rule with the formula like =ISNUMBER($A1)

      To highlight all cells with values other than formulas, use the formula like =AND(ISFORMULA($A1)=FALSE, $A1<>"") The non-format rule with the ISFORMULA function is not needed in this case.

    2. Hi Rick,

      To leave the cells with formula blank, create a rule with the ISFORMULA function (no background or fill color is selected for this rule) and make sure it comes first in the list of rules, e.g. =ISFORMULA($A1)

      To highlight the numbers entered manually with orange, you can create a rule with the formula like =ISNUMBER($A1)

      To highlight

  40. How can I create a condition for a spreadsheet in which column A will tell me which cell on that row has a value of $0.00? Not a blank value but the actual value of $0.00.

    1. Hi Nikki,

      Select the entire column A and create a rule with the following formula:

      =AND($A1=0, $A1<>"")

  41. I have a date in my one cell and I want to highlight the another cell only if the date in particular month and also I want to count if my color code change from above condition.
    please help....

    1. Hi PRATIK,

      To highlight one cell if another falls withing a certain month, you can create a rule with the following formula:

      =MONTH($A2)=1

      Where A2 is the top-most cell in the dates column and 1 is the month (Jan in this example).

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

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

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

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

          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.

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

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

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

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

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

Post a comment



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