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

Learn how to quickly highlight the entire row based on a single cell's value in Excel. Tips and formula examples for number and text values.

Last week we discussed how to change the background color of a cell based on its value. In this article you will learn how to highlight entire rows in Excel based on a value of one cell, and also find a few tips and formula examples that will work with numerical and text cell values.

How to change a row color based on a number in a single cell

Say, you have a table of your company orders like this: Source data - a table of the company's orders

You may want to shade the rows in different colors based on the cell value in the Qty. column to see the most important orders at a glance. This can be easily done using Excel Conditional Formatting.

  1. Start with selecting the cells the background color of which you want to change.
  2. Create a new formatting rule by clicking Conditional Formatting > New Rule… on the Home tab. On the Home tab, click Conditional Formatting > New Rule…
  3. In the "New Formatting Rule" dialog window that opens, choose the option "Use a formula to determine which cells to format" and enter the following formula in the "Format values where this formula is true" field to highlight orders with Qty. larger than 4:

    =$C2>4 Open the 'New Formatting Rule' dialog and enter the needed formula.

    And naturally, you can use the less than (<) and equal to (=) operators to find and highlight rows that have Qty. smaller than 4 or equal to 4:

    =$C2<4

    =$C2=4

    Also, pay attention to the dollar sign $ before the cell's address - it is needed to keep the column letter the same when the formula gets copied across the row. Actually, it is what does the trick and applies formatting to the whole row based on a value in a given cell.

  4. Click the "Format…" button and switch to Fill tab to choose the background color. If the default colors do not suffice, click the "More Colors…" button to pick the one to your liking, and then click OK twice. Click the 'More Colors…' button to choose the color to your liking.

    You can also use any other formatting options, such as the font color or cells border on the other tabs of the Format Cells dialog.

  5. The preview of your formatting rule will look similar to this: The preview of your formatting rule
  6. If this is how you wanted it and you are happy with the color, click OK to see your new formatting in effect.

    Now, if the value in the Qty. column is greater than 4, the entire rows in your Excel table will turn blue. Highlight entire rows based on a cell value.

As you can see, changing the row's color based on a number in a single cell is pretty easy in Excel. Further on, you will find more formula examples and a couple of tips for more complex scenarios.

How to apply several rules with the priority you need

In the previous example, you may want to highlight the rows with different values in the Qty. column in different colors. For example, you can add a rule to shade the rows with quantity 10 or greater. In this case, use this formula:

=$C2>9

After your second formatting rule is created, set the rules priority so that both of your rules will work.

  1. On the Home tab, in the Styles group, click Conditional Formatting > Manage Rules… .
  2. Choose "This worksheet" in the "Show formatting rules for" field. If you want to manage the rules that apply to your current selection only, choose "Current Selection".
  3. Select the formatting rule you want to be applied first and move it to the top of the list using the arrows. The result should resemble this: Use the up and down arrows to set the rules' priority.

    Click the OK button and the corresponding rows will immediately change their background color based on the cell values that you specified in both formulas. The entire rows colored based on two conditional formatting rules

How to change a row color based on a text value in a cell

In our sample table, to make follow-up on orders easier, you can shade the rows based on the values in the Delivery column, so that:

  • If an order is "Due in X Days", the background color of such rows will turn orange;
  • If an item is "Delivered", the entire row will be colored in green;
  • If an order is "Past Due", the row will turn red.

Naturally, the row color will change if the order status gets updated.

While the formula from our first example could work for "Delivered" and "Past Due"(=$E2="Delivered" and =$E2="Past Due"), the task sounds a bit trickier for "Due in…" orders. As you see, different orders are due in 1, 3, 5 or more days and the above formula won't work because it is purposed for exact match.

In this case, you'd better use the SEARCH function that works for the partial match as well:

=SEARCH("Due in", $E2)>0

In the formula, E2 is the address of the cell that you want to base your formatting on, the dollar sign ($) is used to lock the column coordinate, and >0 means that the formatting will be applied if the specified text ("Due in" in our case) is found in any position in the cell.

Create three such rules following the steps from the first example, and you will have the below table, as the result: The rows' color is changed based on a text value in a cell.

Highlight row if cell starts with specific text

Using >0 in the above formula means that the row will be colored no matter where the specified text is located in the key cell. For example, the Delivery column (F) may contain the text "Urgent, Due in 6 Hours", and this row will be colored as well.

To change the row color when the key cell starts with a particular value, use =1 in the formula, e.g.:

=SEARCH("Due in", $E2)=1

in this case, the row will only be highlighted if the specified text is found in the first position in the cell.

For this conditional formatting rule to work correctly, make sure there are no leading spaces in the key column, otherwise you might rack your brain trying to figure out why the formula does not work :) You can use this free tool to find and remove leading and trailing spaces in your worksheets - Trim Spaces tool for Excel.

How to change a cell's color based on a value of another cell

In fact, this is simply a variation of changing the background color of a row case. But instead of the whole table, you select a column or a range where you want to highlight rows and use the formulas described above.

For example, we could create three such rules to shade only the cells in the "Order number" column based on another cell value (values in the Delivery column). Changing a cell's color based on a value in another cell

Highlight rows based on several conditions

If you want to shade the rows in the same color based on several values, then instead of creating several formatting rules you can use the OR or AND functions to set several conditions.

For example, we can color the orders due in 1 and 3 days in the reddish color, and those that are due in 5 and 7 days in the yellow color. The formulas are as follow:

=OR($F2="Due in 1 Days", $F2="Due in 3 Days")

=OR($F2="Due in 5 Days", $F2="Due in 7 Days") Use the =OR formula to change a row's color based on several conditions.

And you can use the AND function, say, to change the background color of rows with Qty. equal to or greater than 5 and equal to or less than 10:

=AND($D2>=5, $D2<=10) An example of using the =AND formula

Naturally, you are not limited to using only 2 conditions in such formulas, you are free to use as many as you need. For example:

=OR($F2="Due in 1 Days", $F2="Due in 3 Days", $F2="Due in 5 Days")

Tip: Now that you know how to color cells to differentiate between various types of values, you may want to know how many cells are highlighted in a certain color and calculate the sum of values in those cells. The good news is that you can automate this too and you will find the solution in this article: How to count, sum and filter cells by color in Excel.

These are only a few of many possible ways to zebra stripe your Excel worksheets based on a cell's value that will respond to change of data in that cell. If you need something different for your data set, drop us a comment and we will try to figure this out.

534 comments

  1. I am trying to change the row colour based on the word 'PAID' in one cell but I cannot make it work. I have tried all that you have suggested above and am at the point of tearing my hair out! please help!

    • Hi Dee,

      Try this:

      - Select all the rows you want to color, excluding the header row, if any.
      - Go to Conditional Formatting > New rule > Use a formula to determine which cells to format.
      - Create a rule with this formula =SEARCH("PAID", $C2)>0 Remember to replace C with the name of your column that contains the word PAID. If your data starts in a row other than 2, replace 2 with the corresponding row number.

      If the formula still does not work for you, please send me your sample workbook at support@ablebits.com and we will figure out the cause.

  2. Hi Svetlana,

    Lets say there are two colums
    A B
    11 13
    12 9
    13 15
    5 55

    If the value of B is greater than that of a, the value in B should be green color else red. How do i go about doing that?
    Thanks
    J

  3. Hi,

    I have a problem with icon sets. I'm supposed to obtain green flag in cell A5 if there is any value (combination of letters and numbers) in cell F5 and red flag in the case that there is no value. I need a solution for entire column A (flags) and F (values).

    Thank you in avance.

  4. Hi,
    Can you help me in one case
    My requirement is "I just want to highligt the cell (by colour) if any changes done after a particular date.

    • Hi Marina,

      I think this can be done only via a macro. Regrettably, there are no such rules in Excel conditional formatting.

  5. I need a little help...

    I am trying to get the whole row text to change colour based on entries in column S.

    I go to conditional formatting and choose a new rule. I then pick use a formula to determine which cells to format. I then put the following formula in: =$S7="2015 callback"

    I change the format so that the text will change to purple.

    Once I have done all this some cells change but these are rows of cells where the information in column s is not "2015 callback"

    How can I manipulate this excel spreadsheet to do as I want?

    Thanks

    • Hi Laura,

      Your formula is correct. Just make sure please that you apply it to the right range of cells. For example, if row 7 is your first row with data, then you should select the range starting with A7.

      If your data starts in some other row, e.g. row 2, then you should change the formula accordingly: =$S2="2015 callback"

      I have created a similar rule for column C and it works just fine:
      Conditional formatting rule

  6. Hi ,

    I am able to achieve conditional formatting , but i also have hierarchy in my sheet , so after applying conditional formatting if i try expanding hierachy my foramtting is disappearing .

    Can you please help , I have applied applied sap styles for my hierarchy.

    How to lock the conditional formatting , i mean it should retain/remain after expanding hierarchy.

    Thanks in advance.
    Mamatha

    • Hello Mamatha,

      I am sorry I do not quite understand what exactly you mean by "hierarchy" in your sheet. Is it group subtotal or something else? Anyway, it would be easier to determine the source of the problem if I could have a look at your data. You can send me your worksheet at support@ablebits.com and I will do my best to help.

  7. Hi Svetlana,

    Could you please help me
    I try to use formula, for example

    =SEARCH("anymatch",A1)

    But catch error "We found a problem with formula... Now trying to type a formula? When the first character is an exusal (=) or minus (-) sign, Excel thinks it's a fomula"...

    And I can't save Formatting rule.

    Thanks

    • Hi Alexey,

      If you have the Russian regional settings, then you should use a semicolon instead of a comma in your formula (unless you changed this in the regional setting in control panel).

      Also, please note that if you want to find the specified text in any position in a cell, the formula reads =SEARCH("anymatch";A1)>0. If a cell's contents should start with the specified text, then use =SEARCH("anymatch";A1)=1

      If the error persists, please let the know the full formula, exactly as you are entering it in a rule. In this way, it would be easier to test and pin down the root of the problem.

  8. How would I do this if I wanted it black out a row with any text in a column cell? For example a termination date. If there is any date entered in that column it blacks that employees info.

    Thanks

    • Hi Kyle,
      You can select the entire table and create a rule with this formula (assuming that your table has headers and data starts in row 2):
      =$B2<>"" where B is your termination date column. Naturally, you choose the black fill color.

  9. I am trying to format a sheet so that when a date is entered in a row in column K the entire row is coloured yellow. However when a second date is entered in the same row in column L the row is changed to red. I know this should be simple but I am having issues getting it to work.

    • Hello Lu,

      I think you can create 2 rules with the following formulas and apply them to the entire table:
      1) =$K1<>"" - yellow fill color
      2) =AND($K1<>"", $L1<>"") - red fill color. Check the option "Stop if true" next to this rule and make sure it comes first in the rule list.

      The rules will color your spreadsheet correctly if only dates are allowed in columns K and L, because as you understand, the formulas will work if any value is entered in those 2 columns. Hopefully, this solution is suitable for your task.

  10. Hello. I am trying to use your formula but somehow I am missing something. I want to highlight the entire row in green if C1 has the text "completed". Not sure what I'm doing wrong.

    • Hi Thelma,

      You can do this by selecting the entire table where you want to color the rows and creating the conditional formatting rule with this formula:
      =$C1="completed"

      If C1 may contain some other words, e.g. "completed last week", then you can use this formula for partial match.
      =SEARCH("completed", $C1)>0

      Also, make sure you use straight quotes in the formula, they are often changed to smart quotes when copying / pasting from web-pages.

      If the rule still does not work, please send me your workbook at support@ablebits.com and I will try to help.

  11. Great tutorial. Is very helpful and saved my time lot. Thank you.

  12. Hi! I have a lot of columns in a worksheet. If there is a number greater than 0 in a cell of 1 specific column, I want the first cell of the row where the number greater than 0 is located to become highlighted. Is that possible?

    It is not highlighting the entire cell but a cell in that row. Thanks in advance!

    • Hi,

      Yes, you can do this in the following way:
      - Select only the column where you want to color cells (except for the header row, if any). Suppose this is column A.
      - Create a conditional formating rule with this formula: =$C2>0 where C is your specific column. If your table does not have headers and your data starts in row 1, then use =$C1>0

      Since we use a mixed reference in the formula (absolute column and relative row), the formula will highlight the first cell (A) of each row where the value in column C in greater than 0.

  13. Hello, I have an easy one. I need to highlight today's date row and then the next row as well (not just the next date). I have multiple rows for one date box.
    ex: 1/1/14 row a highlight this row
    row b highlight this row
    1/2/14 row a
    row b

    I have today's date row highlighted, but now the row b. The Row b first box covers and row a first box is the same box expanded over the two rows.

    • Hi Josh,

      You just need to create one more rule for the same range with this formula =TODAY()=$C1

  14. How do I get an icon set to plot on a graph based on data results from a survey?

    • Sorry, I do not exactly understand what you are trying to achieve. Please send us (alexander.frolov@ablebits.com) a screenshot of the desired result and your sample data and we will try to figure out a way.

  15. okay i got it... Its in the font tab while creating the rule.

  16. Hi,

    If i want to change the font color based on cell color what should i do

  17. Hi Svetlana,

    I got it to work. Thank you very much

  18. Hi Svetlana,

    I still can't seem to get it right. Maybe I should explain better. I have text in column C and then have values in some of the other columns. my text in column C reads "PC AMOUNT" and when I type this in I want the specific row from column A to Column G to turn a specific colour.

    When I use the formula you gave, and I type in "PC AMOUNT" where "text" is, it gives me an error. " you may not use reference operators "

    Can you perhaps assist.

    Thank you

    • Hi,

      I have tried to create a rule with this formula =$C2="PC AMOUNT" and it worked fine on my test data. Just make sure that you use the straight quotes in Excel, because this blog converts them to smart quotes and this does cause the error you mentioned when copying/pasting formulas directly.

  19. Hi, I am struggling with the following:

    I have a certain text in Column C and want that certain row from A to G to be a specific colour when the text is written in column C. can you please help me?

    thank you

    • Hi,

      If you want to highlight the row with exact match in Column C, then select your table and create a rule with this formula:
      =$C2="text" (assuming that your table has headers and row 2 is your 1st row with data)

      If you want to highlight the row with partial match, i.e. Column C may contain a certain text preceded or followed by some other text, then use this formula:
      =SEARCH("text", $C2)>0

  20. Hi Svetlana
    I used VLOOKUP function to fetch the desired row and show it elsewhere and it works.
    I hope can find a solution for my 2nd Q. I think i should use some codes in excel VBA. Unfortunately I have no idea about that.

    • Hi Morteza,

      To my best knowledge, it is not possible to display a certain row as a pop-up in Excel, at least I do not know any means to achieve this. I am really sorry.

  21. I made a table which uses a simple formula to calculate the profit of deposit money then shows the result. Each row stands for a day.And now, i want the row of containing current day result can be shown on screen automatically (something like a pop up message)when I logs in to my account.and afterward by clicking a button or icon whenever I wish. In summary I WANT A ROW OF DATA IN EXCEL 2007 BE SHOWN ON DESKTOP LIKE A POP UP WINDOW AT START UP.I hope I explained it clearly.

  22. THANKS

  23. Hi all,

    How to send a specific excel data as a pop up message on desktop by these rules:

    1- Auto pop up at start up
    2- By user click
    3- contents data varies based on computer current date.

    Does anybody know How?

    Thanks

    • It is very difficult or probably impossible to display a pop-up on desktop. You can get the dialog to appear in Excel upon opening a workbook and /or clicking a button in the workbook. The question is what exactly you want to write in that dialog?

  24. Hi Svetlana
    At first i should thank you for your helpful advice to clear my mind about some problems.
    But now,i encounter another problem and hope i can describe it well.

    1- I made a table that calculates the benefit of a deposit money then shows it in a cell(all in a row).It also highlights the row of current day "today()" nfo.
    Since it has too many rows it takes time to find the right one, so i want to show the exact data based on current day in different place for example at the top of the sheet.

    2- Is it possible to show this new row on screen when a user log-in. (something like pop up text ).

    Thanks for your hints even if it doesn,t solve my pb.

    • Hello Morteza,

      Thank you very much for your kind words! Regrettably, I do now know a way to show a certain row at the top of the sheet. Really sorry for not being able to help you.

  25. Hi Svetlana

    Thank you for you good work.
    How do you change the color of a value in a cell that has changing (RTD) dynamic value:
    Example:
    Cell A1 contents 1000 Text color is BLACK time 00:01
    Cell A1 contents 1001 Text color is GREEN time 00:02
    Cell A1 contents 999 text color is RED time 00:03
    Thank you
    Ian

    • Hi Ian,

      You can try to do this by creating 3 different rules of the type "Format only cells that contain" that apply to the entire table. Please see this example for step-by-step instructions: How to change a cell's color based on value.

      Though, I have to say I have never tested the conditional formatting rules on data returned by an RTD and cannot say with confidence whether this will work.

  26. thnx alot. this was very helpfull

  27. Hi Svetlana,

    how to highlight first order row of every client? My spreadsheet contains client name, date of acquisition columns and has many entries per client.

    Many thanks!

    • Hi Marcel,

      I cannot figure out a way to do this with conditional formatting. However, our Duplicate Remover add-in can help. You can download a trial version and then do the following:

      1. Select your entire table, and click "Duplicate Remover" icon on the ribbon, then click Next.
      2. Choose to find "Uniques +1st occurrence".
      3. Select only your "Client ID" column as the key column.
      4. Select the action "Fill with color", choose a color and click Finish.

      The first order row of every client will be shaded with the color of your choosing. Is this what you are looking for?

  28. Hi Svetlana,
    I cannot set a conditional (color) format in (say) cell A1 based on A2 if A2 is a formula. If I type in a hard number into A2 then A1 goes red - it works fine - but when I put the formula back into A2(which delivers the correct answer itself for my spreadsheet)then A1 does not respond ?
    Please help.
    Many thanks
    Owen

    • Hi Owen,
      In theory, this should work with formulas too, unless you use something very specific. Could you give an example of your real formula, probably this will give me a clue?

  29. Hi svetlana,

    Have another query. Its related to Macro. I have two different work sheets. from the first sheet i have to copy two separate cells and have to paste that in the second sheet. after i paste i will get values generated in the second sheet. then i have to copy the generated values and paste it in the first sheet. this has to keep on goin on a loop. how to do this.

    For example from first sheet i will copy distance and speed and paste in the second sheet. based on these values cost will be automatically generated in the first sheet. and then i have to copy these costs and paste in the first sheet. Then i have to copy next two values of distance and speed from sheet 1 and paste in sheet 2. this has to go as a loop.And the sheets should automatically open.

    Chris

  30. thank you..

  31. Hai Svetlana,

    Thanks for your reply. Second part worked perfectly. But for the first part when i say start date as 20/03/2014 and duration as 2 days then it should consider 20th also. so the end date should be 21/03/2014.

    Cheers
    Chris

    • Hi Chris,

      In this case, the correct formula is this =WORKDAY.INTL(A1-1,B1,7)

      However, please note that if your start date as 20/03/2014 and duration as 2 days, the end date will still be 23th because March 21 and 22 are Fri and Sat, respectively, and they are days off according to your requirements.

  32. Hi. Thank you for the helpful instructions. I am trying to set the color of a row based on the text in one column, but have a list of words to exclude.
    Therefore, I want the rows where certain words do not appear in a specific column to be highlighted. I would greatly appreciate your help.

    I have tried the following formula without success
    =AND($F17"BLUE", "RED")

    and
    =OR($F17"BLUE", "RED")

    • Hi Abby,

      If my understanding is correct, you need to highlight rows where neither "BLUE" nor "RED" appears in column F. If so, select your entire table and you can use create a conditional formatting rule with this formula (assuming that your table has headers and row 2 is your 1st row with data):
      =AND($F2<>"RED",$F2<>"BLUE")

      If you want to highlighted rows that contain certain words, let's name them "GooodWord1" and "GooodWord2", but do not contain words-exceptions, say "ExcludeWord1" and "ExcludeWord2", then you will need a very complex formula like this:

      AND(false=ISERR(SEARCH("GooodWord1",$F2)), false=ISERR(SEARCH("GooodWord1",$F2)), true=ISERR(SEARCH("ExcludeWord1",$F2)),, true=ISERR(SEARCH("ExcludeWord2",$F2)))=true

      As you see this formula is very long and that is why your workbook may start working a bit slower than usually.

  33. How to use Conditional Formatting in total Row Like

    Name Age City
    Jaslok 20 Delhi
    Ramesh 21 Jabalpur
    Rama 22 Kanpur

    • Hi Pratap,

      It depends on what exactly you want to do. If you can give me some more details about your task, I'll probably be able to help.

  34. I am creating a template and I have queries in that. It’s in two parts.

    First Part
    I have a start date of a work. And the no of days the works is going on. In the next column I should get the end date. But it should add the weekends. (For example my works starting date is 13/03/2014 and the no of days of work is 2. Then the work ending date should come as 16/03/2014. (Weekend is Friday and Saturday. Not Saturday and Sunday). I tried using “workday” command but I think it assumes (Saturday and Sunday as weekends).
    Task Name Start Date Duration End Date
    Survey 13/03/2014 2 ?

    Second Part
    There are dates in the column. As per the start date and the end date that we have calculated from part 1 the cells should color automatically. Say if it the work is from 13 to 16th then the cells between these two dates should be automatically colored.
    Start Date End Date 13 14 15 16 17
    13/03/2014 16/03/2014

    Can you help me to do this excel.

    • Hi Chris,

      You can achieve the desired results in this way:

      Part 1: Use this function =WORKDAY.INTL(A1,B1,7) Value 7 indicates Friday and Saturday as holidays. You can find the complete list of the weekend number values here:
      https://office.microsoft.com/en-001/excel-help/workday-intl-function-HA010354380.aspx

      Part 2: You can try creating a conditional formatting rule with this formula: =AND(D2>=DAY($A2),D2<=DAY($C2))
      Assuming that row 2 is your 1st row with data, A2 is the start date, C2 is the end date, and D is the column containing "13 14 15 16 17".

  35. Hi Svetlana,

    I sent you an email.. hope we can get this solved.

    • Hi Steve,

      I emailed you back the result.

      The Search formulas work just fine, just make sure you use the first cell with data in the formula, which is D3 in your case:
      =SEARCH("Passed", $D3)=1
      =SEARCH("Annual", $D3)=1

      Also, it is important that you enter the range with your data only under "Applies to" and not the entire column, otherwise the formula will be applied to the first 2 rows too and you will get incorrect results.

  36. Hi Steve,

    Select cells in Colum C that you want to format and create rules with these formulas (assuming that row 2 is your 1st rows with data):
    Orange: =SEARCH("Annual", $B2)=1
    Green: =SEARCH("Passed", $B2)=1

    This should color cells in Column C when the corresponding cells in column B contain Annual and Passed, respectively. If you are looking for something different, please send me a sample workbook at support@ablebits.com and we'll try to figure this out.

  37. Hi Svetlana,

    I have 2 columns-- in one is the Event Name and the other is Event Type

    I want the event name in column C to change color based on the 3 types of events I type in column B

    so if you type Annual I want that event name to change Orange
    if you type Passed I want that event name to change Green

    My problem is its changing ALL of the events the colors because it contains the word annual..

    please help!!

  38. Hi Svetlana,

    for my work i need to enter different values for each row every time.
    i would like for the coloring of the new entry to be automatic to green.
    and i want the previous record to be white again. meaning i want always the latest entry will be colored and the rest colorless.

    is there an easy way to achieve this.

    much thank,

    Joe

    • Hi Joe,
      This is not possible to achieve using Excel's conditional formatting. Our Excel specialist has written a small macro for you that shades the latest edited cell in green. You can try this solution by copying the macro to your worksheet:

      Private Sub Worksheet_Change(ByVal rnUpdated As Range)
      Static strLastUpdated As String

      If strLastUpdated <> "" Then
      Range(strLastUpdated).Interior.ColorIndex = 0
      End If

      rnUpdated.Interior.Color = CLng("&H00FF00")
      strLastUpdated = rnUpdated.Address

      End Sub

      If you are not very comfortable with macros, this short tutorial may be helpful:
      How to insert and run VBA code in Excel

  39. I have a large spreadsheet that contains two date columns. One of the date columns is column F. I want to highlight every row that has the date 12/31/2013 in column F, but I can't make it work. Thanks!

    • Hi Katie,

      The point is that Excel stores dates as numbers, starting from January 1, 1900. So, 1-Jan-1900 is stored as 1, 2-Jan-1900 as 2… and 12/31/2013 as 41639. To make the formula work, just enter your date in this numerical format, i.e. =$F2=41639 (assuming that row 2 is your top row with data).

      Another way is to convert the date to the number format is which it is stored: =$F2=DATEVALUE("12/31/2013")

  40. it is not helpful to me as no formula to change the entire row color is sucessful. i want to know how a row will be coloured if a value change. thanks

    • Regrettably, I'm not able to give any advice without knowing what exactly you are trying to achieve. If you can give an example of your data (including column names), we will try to work out a proper formula.

  41. Hi, If I want to highlight a final result cell based on certain inputs, say "Yes" or "No" in a column. how can i do that?

    If the column C has Yes or No as inputs against some conditions placed in column B then how does it reflect in the final result column D as Yes or No?

    • Hi AG,

      If my understanding is correct, you want to copy "Yes" or "Now" from column C to column D and then highlight rows in 2 different colors. If so, then enter the following formula in cell D2 (assuming that your table has headers) and then fill that down until the end of your table: =C2

      After that select your table and create 2 rules using these formulas:
      To highlight rows with Yes: =SEARCH("Yes", $D2)=1
      To highlight rows with No: =SEARCH("No", $D2)=1

      If you are looking for something different, please clarify.

  42. I have a spreadsheet in which I have a number of columns. In column a I have a Code that may repeat for 4 rows, then change to another value, then another. How can I easily Highlight the row for each change in column A? Here is a simple example of the data. In the case below, I would want to highlight the first 4 rows in let's say blue, then I do not need to highlight rows 5-8, but then highlight rows 9-12 in blue again, the next 4 no highlight, etc...

    6870meri Property Administrator (Payables)
    6870meri Property Administrator (Receivables)
    6870meri Property Manager
    6870meri Superintendent
    aberdeen Property Administrator (Payables)
    aberdeen Property Administrator (Receivables)
    aberdeen Property Manager
    aberdeen Superintendent
    albionc Property Administrator (Payables)
    albionc Property Administrator (Receivables)
    albionc Property Manager
    albionc Superintendent
    alexandr Property Administrator (Payables)
    alexandr Property Administrator (Receivables)
    alexandr Property Manager
    alexandr Superintendent
    alkenton Property Administrator (Payables)
    alkenton Property Administrator (Receivables)
    alkenton Property Manager
    alkenton Superintendent
    arcadia Property Administrator (Payables)
    arcadia Property Administrator (Receivables)
    arcadia Property Manager
    arcadia Superintendent

    • Hi Peter,

      If all of your codes repeat for 4 rows, then you don't even need to use conditional formatting. An easier way to zebra stripe your data would be using Excel's table styles:

      1. If you have a range of data, convert it to table (Insert > Table).
      2. Go to the Design tab, right click on the table style you want and choose Duplicate.
      3. Name your new style, select "First Row Stripe" and set it to 4. Do the same for "Second Row Stripe".
      4. Click OK, save your style and apply it to your table by selecting it from the Table Styles gallery.

      You can achieve the same result by creating a conditional formatting rule with this formula =MOD(ROW($A2)+8-2,8)>=4 (supposing that your table has headers and row 2 is your top row with data; if not, then replace -2 with the number of your 1st row).

      If there may be a different number of rows in the Codes column (A), then you will need a bit more complex formula. Create an additional column, say column K, and enter the following formula in cell K2, then copy it across the entire column: =MOD(IF(ROW()=2,0,IF(A2=A1,K1, K1+1)), 2)

      The formula will populate column K with blocks of 0 and 1, every new block staring with the Code change. After that create a conditional formatting rule(s) using the formula =$K2=1 (and =$K2<>1 if you'd want a second color to alternate blocks). Hope this helps.

      • Much thanks...this will be simple to implement and works like a charm.

  43. Hello,

    I was able to use your directions to change the color of one cell based on the values in another. I would like to repeat this on every row in my document. Each row is in an independent decision. Is there an easy way to copy my rule for one row to the others or do I have to set up each row individually? Thank you.

    • Hi Carl,

      If you want to apply the same rule to all the rows, then you can simply modify the range it applies to. You can do it in the following way. Select the row to which the rule applies, click Conditional Formatting > Manage rules, select your rule and enter the needed range directly in the “Applies to” field. If you are loking for something different, then please give me an example.

      • I don't think setting a range will work because the color of cell A1 (in my sheet) is dependant upon a value in A10 and/or A11. The value in B1 will be dependant upon my value in B10 and/or B11 and so on. Each row is an indpendant decision of the other rows. If I apply a range then won't all the colors be the same? I don't want that. A 1 could be anyone of three colors, B1 could be anyone of three colors and so on.

        • Hi Carl,

          I am not sure I understand your task correctly. Anyway, for the colors not to be the same, you can use a relative reference (without the $ sign) or a mixed reference (relative column and absolute row). For example, if you create a conditional formatting rule with this formula =AND(A1>A$10,A1<A$11) for range =$A$1:$D$9, it will color all cells in column A (A1:A9) whose values are greater than A10 and less than A11; cells in column B with values greater than B10 and less than B11 and so on. If you are looking for something different, then you can send us your test workbook (support@ablebits.com), it's always much easier to come up with the right formula when you can see the real data.

  44. Hi Svetlana,

    I am trying to use the AND function to highlight rows. I want the row to be shaded when column K and column M contain "Yes". I highlight my whole table and apply the conditional formatting rule =AND($K5="Yes",$M5="Yes")it works but only for the top row? How do I make it so the rule is applied to the whole table?

    Also if possible, I would like to shade a different colour when the above is applied and also column I contains any value (either text or number). Is this possible?

    Thank you, I hope this make sense!

    • Hi Shannon,

      Your formula is correct and it worked just fine on my test sheet. It might not work on your side if for some reason your conditional rule was created for the top row only. You can check it in this way:

      On the Excel Ribbon, click Conditional Formatting > Manage rules. In the Conditional Formatting Rules Manager, choose "This Worksheet" next to "Show formatting rules for". You will see your current rule and the range it applies to. If it is not correct, you can change it directly in the "Applies to" field.

      Also, please check if row 5 is really a top row with data in your table, it not, modify the formula accordingly.

      As for your second condition (when columns K and M contain "Yes" and column I contains any value), it is also possible using this formula: =AND($K5="Yes",$M5="Yes",$I5<>"") Hope this helps.

  45. Thank you, thank you! I have been trying to find a way to make this work based on the dates in the last column of several spreadsheets for a week. I guess I was just asking the wrong questions of Google, but today I found your explanation and was able to quickly (and EASILY) alter it to my needs using the TODAY()feature and adding/subtracting the # of days that would determine a different color.

    Your explanations and the screenshots were fantastic!

  46. is it possible to format a cell that contain numeric and text value on its numeric value only?
    Regards

    • Regrettably, this cannot be done either with conditional formatting or Excel formulas because they change the format of the entire cell.

  47. hi! i am traying to format each duplicate pair in diffrent color, is this possible? infact, it is a date format and i want to have each date duplicates in same color.
    regards

    • Hi Muzaffar,

      I don't know a way to do this with conditional formatting. Possibly, there is a way using a VBA macro.

  48. Hi,

    I have created a spreadsheet with a list of contracts including expiry dates when known - I am trying to create a conditional format for the entire row when the contract has expired - I have tried several different combinations including creating a hidden column with the TODAY() formula and using the =$L1<$M1 in the conditional formula L - being the expiry date and M - the today date, but none of the combinations I have tried are working (I have checked and all the dates are entered in the same format - but some dates that are greater than M are being highlighted also....I have also created a conditional format for when the expiry date is empty (L) to leave the format unchanged but it seems to work for some and not for others - I am completely stumped?

    • Hi Theresa,
      Your formula is correct. I can think of only one possible reason why it may not work properly. If your table has headers, then you need to put it =$L2<$M2 to avoid the "shift" because the real data starts in row 2. Is this the case?

  49. Hi! You know the formula to highlight the row that have the same values in total score column and rank column? Thanks! :D

    • Hi Josiah,

      You can create a rule with this formula: =$A2=$B2

      Where A and B are your total score and rank columns and 2 is the first row with data. Hope this helps : )

      • I mean, in my case, T9 and T10 have the same rank. Is there a formula to highlight them? C:

        • Hi Josiah,

          Sorry, I am not sure I can exactly follow you. I thought you needed to color rows if values in 2 different columns (total score and rank) were the same. But T9 and T10 are 2 different rows in the same column.

  50. I have one help
    in a cell i have keying one letter example A, and i selected same row its reflect full rows A.
    how is i do. need to help me.

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