Comments on: How to change the row color based on a cell value in Excel

Learn how to quickly change the color of the entire row based on a single cell's value in your Excel worksheets. Tips and formula examples for number and text values. Continue reading

Comments page 10. Total comments: 546

  1. Hi admin

    how to highlighted condtional formatting color row A number above row B also colour not updated 0.

    Regards

    SP

  2. I would like to be able to change a row to a colour if the cell G2 contains "A" to yellow "B" to green and "C" to red. I would like to continue this in all rows of column G. My issue is I can do this for row 2 but when I try to do it for the column G when I put text in 'G2' it changes all other rows.
    Will I have to create a macro?

    1. Hi Karl,

      A macro is not needed in this case, the task can be handled by a conditional formatting rule. The key point is to use proper cell references - absolute column and relative row: =$G2="A"

      Also, make sure you apply the rule to a range beginning with the same row as referenced in the formula, row 2 in your case.

  3. Hi admin

    how to highlighted condtional formatting color col A number above col B also colour not updated 0.

    Regards

    SP

  4. Hi Admin

    What i want is really very simple but im having trouble.
    i have 6 colums 2A to 2F i want all the background colours red there will be a number in colum 2A and 3A and when i put a number in colum 4A i want all colums 2A to 2F to change to gree ?

    Regards
    justin

  5. Hi,

    I am having trouble changing cell colours for some reason. I have used the formulas as suggested but the formula will not work. I'm not sure what I am doing wrong! I want to change the colour of the cells in the L column if they are blank and if the cells in the W column have been entered as 'No'. I have entered the formula as =AND(L2="",W2="No"). Could you tell me what I am doing wrong as I cannot work it out?

    Many thanks

    1. Hi Farhat,

      The formula is correct. Just make sure the rule applies to column L beginning with cell L2. Also, you'd better fix the columns by using the $ sign:
      =AND($L2="",$W2="No")

  6. Hey Admin. Hoping you could help me out here.
    In my excel sheet i have columns for start date, number of months and end date. If the number of months is 7, 2 columns, i.e column D and E must get highlighted. If number of months is 3, columns D,E and F must be highlighted. How can i do this. Please help.

  7. I have a data with Columns; Entry No, Date, Activity, Target Date, and Completion Status.
    I want My rows color to change based on Target Date and Completion Status.
    if Target date is within 7 days row colour must be Orange.
    if Target date is due row colour must be red.
    If Completion status is completed row colour must be Green
    pls hlp me

  8. Thanks for answering all of our questions!

    I have a problem with using this formula.

    I have 9 columns A to J

    i'd like to have a row changed to a specific colour depending on the contents of the cell in column C

    C has two states, 'INSTALLED' and 'REMOVED'

    essentially if the cell reads 'REMOVED' then i want that row to be colored yellow. If it reads 'INSTALLED' i want it colored green.

    It seemed like you already covered this in the article but your process did not work for me. I even tried adding new test rows and changing the value of the cell in column C but there was no change.

    The formulae i used were "=$C="REMOVED" and "=$C=INSTALLED"

    Thanks for your help!

    1. Hi Bob,

      You need to refer to your top-most cell in the formula. For example, if your data begins in row 2, the formulas are as follows:

      =$C2="REMOVED"
      =$C2="INSTALLED"

      1. after trying it again, i realised that i had selected the cells using the column headers rather than selecting the cells by draggin a selection or shift-clicking.

        All seems to work now!

        Thanks!!!

  9. Thanks for your help Svetlana, that is almost perfest but I want the formula to work whatever date I put in column M, is it possible? :-)

    1. Julie,

      Of course, it's possible. In this case, the formula is even simpler :)

      To color a row if a cell in column M is not empty (contains any value - number, date or text):
      =$M2<>""

      To color a row if a cell in column M is a number or date (dates are stored as serial numbers in Excel), but do not color a row if column M contains a text value:
      =ISNUMBER($M2)

  10. your blog has helped me so much but I just need a bit more help, I am using the following formula to shade a whole row green once the word 'completed' has been added to cell M but I would really like this to be a 'date' rather than the word 'completed', I have tried a few things but I am a beginner on excel. The formula I am using is =$M2="COMPLETED" is there an easy way to change this to a date? thanks in advance

    1. Hi Julie,

      If you want to highlight a row when a certain date is entered in column M, you can use a formula similar to this:
      =$M2=DATEVALUE("01/01/2015")

      You can find more formula examples of Excel conditional formatting for dates in the following tutorial:
      https://www.ablebits.com/office-addins-blog/excel-conditional-formatting-dates/

      If you don't find an answer there, please elaborate a bit on your task and we will try to make a proper formula.

  11. I column that contain numbers ranging from -001 to -374.

    I want to have a cell that if I type in a matching number to any of the -001 to -374, then the row containing the matched number will be highlighted.
    Please can you help.

  12. Hello Svetlana,
    I want to get the next cell in my row to have a specific color highlight depending on my current cell having a date or number or text. I want a different color for each type of entry. I am a novice and have researched much. I have found the best info here but i still cant figure it out.
    Any guidance would be appreciated.
    Thank you,

  13. I would like the entire row to be highlighted based on the contents of column I ---- either that there is NO value (rather than ANYTHING) if that's possible.... or if there is a "," in the cell text.
    Thank you so much for any help that you can provide.

    1. Hi Hollywil,

      Before creating a rule, you need to select the entire rows you want to highlight for a rule to get applied to several columns rather than a single column.

      Also, when creating a rule, make sure that you select a range of cells beginning with row 2. You can use the following formulas in your rules:

      Highlight rows with "NO" value in column I:
      =$I2="NO"

      If there is a comma in column I:
      =SEARCH(",", $I2)

    2. Let me try that again.
      I've tried a few of the combinations posted, but it only ever changes the background for the I column, not the entire row. Also, I would like this specific formatting to begin with Cell I2, rather than I1.
      Thanks again.

  14. How about highlighting a block of cells based on the value changes in just a single column.

    For instance, say I have columns A and B. Down column A I have numbers like 1,1,1,2,2,3,3,3,3,4,4,4,5,5,5, and whats down column B is non-consequential for this example. Every time column A changes value (from 1 to 2, 2 to 3, and so on), I want to highlight the cells in both column A and B with a different color. The color can simply rotate between two colors.

    Say it was setup like this (x is just some other information)

    A B
    1 x
    1 x
    2 x
    2 x
    2 x
    3 x
    3 x

    I want A1,A2,B1,B2 to be one color, then A3,A4,A5,B3,B4,B5 to be another, and so on.

    Thanks for the help in advance.

  15. Thank you Svetlana, this article was very helpful.

  16. I have a task I perform on a date and I enter the date into Cell A1. What I want to do is have the cell B1 turn to red when I am 7 days past the date I entered into Cell A1. Can you tell me how to do this?

    1. Hi Bruce,

      Try creating a rule with this formula: =TODAY()-$A1>7

  17. I need to change the colour of the font in the row that the date is three years from today (All expired items). When I use conditional formatting the column the date only changes please help. Regds, Omar

  18. thank you so much Svetlana Cheusheva

  19. Hi Svetlana,

    I am trying to automatic highlight the high value in each row.

    For Example threre are some figure in each coloum i.e. :-

    ColumnA ColumnB ColumnC ColumnD
    1. p 10 15 12
    2. n 15 12 14
    3. q 10 04 20
    4. r 15 20 25

    now, which condition i used that the autmatic highlight the high vlue in each row.

    Regards,
    Prashant Johari

  20. Hi Svetlana

    I am trying to figure how to format my worksheet so that it identifys by changing colour if a number is less than the number it was previously e.g. something weighing 12kg then in the next coloum, ideally they will be 13. But if it ends up weighing less, e.g. 11, then it would highlight this for the entire worksheet not just for the one row/cell.
    Are you able to help me? I am tearing my hair out!
    Thanks
    Sophie

  21. I need a formula that will make cell "A3" turn Green when cells "E3 through L3" contain the letter "Y"

    and also

    "A3" turn Red when cells "E3 through L3" contain the letter "N"

    1. Hi Chris,

      You just need to put all these conditions in the AND formula, like this:

      =AND($E3="Y", $F3="Y", G3="Y", etc.)

  22. Hi Svetlana Cheusheva,
    I wanted to send reminders to the stakeholders while exceeding 3 days from last reminder date. I have used the below formatting but I could not highlight the entire rows and also want to ignore weekends (Saturday and Sunday).
    Formula used, E.g.,
    =$D$2-TODAY()>=3
    Thank you.

    1. Hi Bharath,

      First off, please check whether your rule applies to the entire rows you want to highlight (without the column headers).

      Assuming that the last reminder date is in column D, you need to change your formula as follows:

      =TODAY()-$D2>=3

      Please pay attention that $D2 should be a mixed cell reference (absolute column - with $ and relative row - without $).

      Finally, create one more rule to exclude Saturday and Sunday (do not choose any fill color), move it to the top of the rules list and check "Stop if true" next to it:

      =WEEKDAY(D$2,2)>5

  23. Sir,
    My problem is when I put formula in one the background and font color should change accordingly.
    For example:
    A B C D E F G H I
    1 BUY SELL PROFIT
    RATE RATE /LOSS
    2
    3 2500 3000 500 I WANT THIS CELL BACKGROUND GREEN
    4
    5 6000 5500 -500 I WANT THIS CELL BACKGROUND RED

  24. hi just asking please help how to change the color automatically if i input # 4 it will change in other sheet in the entire row it will change color blue.

    for ex. 1 pink
    2 yellow
    3 green
    4 blue

  25. How to change a row color based on a number in a single cell worked great. Except I also have your formula to count cells by color and the colors for the conditional formatted cells shows as "no color" in the cells formatting.

  26. Hi,

    There is any data in xls but somewhere we are correcting the numbers so i want to highlight such raws where we are doing the correction.

    Can you please help me with this?

    Thanks
    Hardik

  27. Hi Experts,

    I have copy pasted data from some website and pasted the content in a cell , say "HELLOWORLD". HELLO is in blue and WORlD is in black.I need to put a ',' after the blue font. so it looks "HELLO,WORLD"
    Can i do it? if yes how ?

    Note- for limited number of records i could have done it manually but i have lakhs of records and i cannot do it all alone manually.
    I want to automate it with some code.

    Please help

    Thanks in advance
    SSK

  28. Hi,
    Can you please help me with my formula?!

    =OR($D>=20%, $E=8%, $E>=4,$E=3%, $E>=7)
    COLOR GREEN

    =OR($D<=20%, $E<=3),OR($D=4,$E<=6),OR($D=7)
    COLOR RED

    1-3 ranking + ctr >20% = green
    1-3 ranking + ctr 8% = green
    4-6 ranking + ctr 3% = green
    7-10 ranking + ctr <3% = red

    Thanks
    Chantel

    1. Select your column(s) and create 4 rules using the following formulas:

      Green
      =AND($D2>=20%,$E2>=1,$E2<=3)

      =AND($D2=8%,$E2>=1,$E2<=3)

      =AND($D2=3%,$E2>=4,$E2<=6)

      Red
      =AND($D2<3%,$E2>=7,$E2<=10)

      Where D is the CTR column, E is the SERP column.

      You’ll find more details about the usage of AND/OR here:
      https://www.ablebits.com/office-addins-blog/excel-and-or-xor-not-functions/

  29. Hi there, thank you for your helpful article! I am making a two sheet workbook intended to show my company what customers we can contact to let them know a product that they are looking for is coming in on our next shipment. The first sheet is the customer's information and in column A is the style number of the product they are looking for. The second sheet will be where we copy and paste the style numbers of everything we are expecting in on our next shipment. I need to make each row in sheet 1 highlight if the value in column A matches any value in column A of the second sheet. Note, I will be deleting and reentering all style numbers in column A of the second sheet to always be showing our most current shipment, so I cannot enter a specific value to match in the formula because it will always be changing. Thank you for your help on this!

    1. Please post a small sample workbook with your data on our forums and include the result you expect to get. We will try to help.

  30. Awesome, thank you SO much!!

  31. Hi Svetlana

    B10060000005
    B10060000005
    B10060000006
    B10060000006
    B10060000007
    B10060000007
    B10060000008
    B10060000008
    B10060000009
    B10060000009
    B10060000023
    B10060000023

    could you please assist I need to give each row contain the same cell value same color, example entire row contain B10060000005 with green, B10060000008 blue ...etc, thank you

  32. In my excel I have two columns Colum B "Account Type" and Column C "Account name"
    Column C has all the account names such as Global travel etc... and Column B which is account type as either Account or Agency mentioned in the cells

    What I am looking for is to have a formula which highlights cells in column B and C when it finds the word "Travel", "Tour", "Agency" in column C and word "Account" in column B .

    Please note it should only highlight when both these criteria are met

  33. Any one Help me

    Q. 2 If we put the value >0 to <2000 in column B then column C should be red. In conditional formating

    Value Cell Color
    2
    4
    -10
    800
    -1691
    1500
    3500

    Need Solve

  34. Q. 2 If we put the value >0 to <2000 in column B then column C should be red. In conditional formating

    Value Cell Color
    2
    4
    -10
    800
    -1691
    1500
    3500

    Need Solve

  35. If I have a worksheet with data across columns A to G, I want to use the formula =MOD(ROW(),2)=0
    to alternate row colours BUT I need to be able to insert rows sometimes when the data in Column D needs to be the same colour as row above .....

    Thanks in advance

  36. Hi Svetlana,

    Could you please help me.

    I want to change the value of cell based on this condtion.

    if A1 cell is coloured Green and B1 cell has value "Yes"
    than B2 automatically gets converted into "Yes".

    Thanks in Advance

  37. Hi Svetlana,

    Could you please help me.
    For example, if A1 have a text then B1 will be filled by color,
    if A2 have a text then B2 will be filled by color.

    I trying to do the formula, but the result is Even A2 blank, B2 filled by color.
    Any idea for the formula.

  38. I have a Question when we find any data in spreadsheet through Ctrl+F than that cell Present in a colour based how to use this query.

  39. Hello,

    I am trying to make each row change color if within a date range. For example, I would like a specific color for each month. If I type a January date it will be one color, but a February date would be another. I can't seem to figure out how to write the formula for the date range.

    Thanks!

    1. Lets say your dates are in column A. Click in that cell

      Go to Conditional Formatting. New rule..

      Use a formula to determine which cell to format.

      Under formatting values. Type in =A1="January"

      Click format and choose your color for that month. Say okay. The window will disappear.

      Click again on conditional formatting and go to manage rules. First double click the rule. It should be something like = $A$1="January". Remove the dollar sign before the 1. Leave the 1 before the A. In the applies to change it to =$A$1:$last column letter $ lastrow number

  40. Hello

    I'm not sure if posted above, but I have one query.

    I am using the conditional formatting formula to highlight a range of cells in a row based on a single cell.

    I need to do this for 100+ rows. All the same range, but one row after another.

    Instead of creating a new condition for each row and cell, can I copy this and apply to each row?

    For example, cells B2 to J2 will highlight when K2 >0.

    Can I copy this to apply to B3 to J3 when K3>0 and so on?

    I would appreciate any help!

    Many thanks :)

    Chloe

    1. You can usually do this if you use... when$k2>0... This tells it to always use column K. Continue conditional formula as normal.

      Go back to conditional formatting to edit. Under your applies to change it to =$B$2:$J$100. (or whatever your final row is)

  41. I found my error, so used to quotations for references. Just had to follow the directions, substitute my settings, and it worked. Thank you for the tip!

  42. Yeah, I tried the conditional formatting based on an 1000 cell array where I need to highlight rows greater than a value. I even set the range for the values I wanted to check (in a single column, then highlighting the rows that cell is in where my established condition is true).

    I've got nothing. I've got a separate count for the cells in that column where my same condition exists, and I know for sure it is correct.

  43. Hi,svetlana
    Greeting of the day
    I want to formula for automotic bold for example..
    we find something in our data, after find it become automatic bold or color in excel sheet ,plz help us

    1. Hello Rajesh,

      You can create a rule with the formula like this: =SEARCH("text", $A2)>0

      And select "Bold" under the "Font style" on the "Font" tab of the "Format Cells" dialog.

  44. I want a useful formula for colouring if a cell value is less or more than original cell value. example, Invoice value is 5000 in cell D cell colour green/white, if received amount is less than 5000 cell colour to be red.

    pls reply.
    krr sharma

    1. Select column D and create two rules using the following formulas:

      Green Rule: =IF(AND($F2<>"", $D2>=$F2)

      Red Rule: =IF(AND($F2<>"", $D2<$F2)

      Where F is the column with received amount.

      1. HI,

        I tried with this formula, not working, pls clarify formula If I received an amount entire row coloured by green, If received less than amount entire row should be red.

        KRR Sharma

  45. Hiii....
    i want to get a formula & need your help...
    if cell d1=fail, then color of cell a2 is blue..how can i do this?

    1. Hi Nazmul,

      Simply select cell A2 and create a conditional formatting rule using this formula:
      =D1="fail"

  46. Hi Svetlana,

    I have a column of data that I will be adding to each day. It will occasionally be the case that the data I add will be a duplicate value already in the column above. Is there a formula in conditional formatting, that will highlight when this happens. Unfortunately using 'Remove Duplicates' or adding a filter is not sufficient as I just need the value highlighted straight away.

    Would be great if you could help out.

    best wishes,

    George

  47. Hello Svetlana,

    I tried to used the formula shown above, however when I change the dates in the cell to test the formula it does not make the necessary changes. Also, I want to express that I am using the conditionally formatting in a different column in which the dates are being used.

  48. I have a simple need. I need some text in a cell to be of two colors. in "Ending balance: Actual/Budget", the word "Budget" has to be in a different color. When I alter the color on the spreadsheet the program keeps reverting it to black.
    How can I do this?
    Thanks,
    Doug

  49. Hello Everyone,

    I have a report that I am attempting to use a conditional format to highlight a cell when the date which is locate in a different column is prior to 06/17/13. Can anyone assist me in sharing the formula to use.

    1. Hello Toni,

      Select the entire column with the dates you want to highlight (not including the column header, if any) and create a conditional formatting rule using this formula:
      =$A2<"06/17/13 (where A2 is top cell).

  50. Hi Svetlana,
    What if you want to highlight an entire row using a color scale that applies to only one column? That is, in your first example at the top, you have a Qty column, and you could easily select conditional formatting -> color scales, and select the color scale of choice. But if you want to copy that color scale across the other columns, excel thinks you want to update your color scale with the values in those columns. So if you try copying the formatting from column c to column b, it will just turn column b green and column c red (or whatever color scale you've selected). I want to highlight ALL of the rows by the relative order quantities. Is there a non-vba solution for this?

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