In this article, you will find two quick ways to change the background color of cells based on value in Excel 2016, 2013 and 2010. Also, you will learn how to use Excel formulas to change the color of blank cells or cells with formula errors.
Everyone knows that changing the background color of a single cell or a range of data in Excel is easy as clicking the Fill color button . But what if you want to change the background color of all cells with a certain value? Moreover, what if you want the background color to change automatically along with the cell value's changes? Further in this article you will find answers to these questions and learn a couple of useful tips that will help you choose the right method for each particular task.
How to change a cell's color based on value in Excel dynamically
The background color will change dependent on the cell's value.
Task: You have a table or range of data, and you want to change the background color of cells based on cell values. Also, you want the color to change dynamically reflecting the data changes.
Solution: You need to use Excel conditional formatting to highlight the values greater than X, less than Y or between X and Y.
Suppose you have a list of gasoline prices in different states and you want the prices greater than USD 3.7 to be of the color red and equal to or less than USD 3.45 to be of the color green.
Note: The screenshots for this example were captured in Excel 2010, however the buttons, dialogs and settings are the same or nearly the same in Excel 2016 and Excel 2013.
Okay, here is what you do step-by-step:
- Select the table or range where you want to change the background color of cells. In this example, we've selected $B$2:$H$10 (the column names and the first column listing the state names are excluded from the selection).
- Navigate to the Home tab, Styles group, and choose Conditional Formatting > New Rule….
- In the New Formatting Rule dialog box, select "Format only cells that contain" under "Select a Rule Type" box in the upper part of the dialog box.
- In the lower part of the dialog box under "Format Only Cells with section", set the rule conditions. We choose to format only cells with a Cell Value - greater than - 3.7, as you can see in the screenshot below.
Then click the Format… button to choose what background color to apply when the above condition is met.
- In the Format Cells dialog box, switch to the Fill tab and select the color of your choice, the reddish color in our case, and click OK.
- Now you are back to the New Formatting Rule window and the preview of your format changes is displayed in the Preview box. If everything is Okay, click the OK button.
The result of your formatting will look similar to this:
Since we need to apply one more condition, i.e. change the background of cells with values equal to or less than 3.45 to the green color, click the New Rule button again and repeat steps 3 - 6 setting the required condition. Here is the Preview of our second conditional formatting rule:
When you are done, click the OK button. What you have now is a nicely formatted table that lets you see the highest and lowest gas prices across different states at a glance. Lucky they are in Texas :)
Tip: You can use the same method to change the font color based on the cell's value. To do this, simply switch to the Font tab in the Format Cells dialog box that we discussed in step 5 and choose your preferred font color.
How to permanently change a cell's color based on its current value
Once set, the background color will not change no matter how the cell's contents might change in the future.
Task: You want to color a cell based on its current value and wish the background color to remain the same even when the cell value's changes.
Solution: Find all cells with a certain value or values using Excel's Find All function or Select Special Cells add-in, and then change the format of found cells using the Format Cells feature.
This is one of those rare tasks that are not covered in Excel help files, forums and blogs and for which there is no straightforward solution. And this is understandable, because this task is not typical. And still, if you need to change the background color of cells statically i.e. once and forever unless you change it manually again, proceed with the following steps.
Find and select all cells that meet a certain condition
There may be several possible scenarios depending on what kind of values you are looking for.
If you need to color cells with a particular value, e.g. 50, 100 or 3.4, go to the Home tab, Editing group, and click Find Select > Find….
Enter the needed values and click the Find All button.
Tip: Click the Options button in the right-hand part of the Find and Replace dialog to get a number of advanced search options, such as "Match Case" and "Match entire cell content". You can use wildcard characters, such as an asterisk (*) to find any string of characters or a question mark (?) to find any single character.
In our previous example, if we needed to find all gas prices between 3.7 and 3.799, we would specify the following search criteria:
Now select any of the found items in the lower part of the Find and Replace dialog window by clicking on it and then press Ctrl + A to select all found entries. After that click the Close button.
This is how you select all cells with a certain value(s) using the Find All function in Excel.
However, what we actually need is to find all gas prices higher than 3.7 and regrettably Excel's Find and Replace dialog does not allow for such things.
Luckily, there is another tool that can handle such complex conditions. The Select Special Cells add-in lets you find all values in a specified range, e.g. between -1 and 45, get the maximum / minimum value in a column, row or range, find cells by font color, fill color and much more.
You click the Select by Value button on the ribbon and then specify your search criteria on the add-in's pane, in our example we are looking for values greater than 3.7. Click the Select button and in a second you will have a result like this:
If you are interested to try the Select Special Cells add-in, you can download an evaluation version here.
Change the background color of selected cells using "Format Cells" dialog
Now that all cells with a specified value or values are selected (either by using Excel's Find and Replace or Select Special Cells add-in) what is left for you to do is force the background color of selected cells to change when a value changes.
Open the Format Cells dialog by pressing Ctrl + 1 (you can also right click any of selected cells and choose "Format Cells…" from the pop-up menu, or go to Home tab > Cells group > Format > Format Cells…) and make all format changes you want. We will choose to change the background color in orange this time, just for a change :)
If you want to alter the background color only without any other format changes, then you can simply click the Fill color button and choose the color to your liking.
Here is the result of our format changes in Excel:
Unlike the previous technique with conditional formatting, the background color set in this way will never change again without your notice, no matter how the values change.
Change background color for special cells (blanks, with formula errors)
Like in the previous example, you can change the background color of special cells in two ways, dynamically and statically.
Use Excel formula to change background color of special cells
A cell's color will change automatically based on the cell's value.
This method provides a solution that you will most likely need in 99% of cases, i.e. the background color of cells will change according to the conditions you set.
We are going to use the gas prices table again as an example, but this time a couple of more states are included and some cells are empty. See how you can detect those blank cells and change their background color.
- On the Home tab, in the Styles group, click Conditional Formatting > New Rule… (see step 2 of How to dynamically change a cell color based on value for step-by-step guidance).
- In the "New Formatting Rule" dialog, select the option "Use a formula to determine which cells to format". Then enter one of the following formulas in the "Format values where this formula is true" field:
- =IsBlank()- to change the background color of blank cells.
- =IsError() - to change the background color of cells with formulas that return errors.
Since we are interested in changing the color of empty cells, enter the formula =IsBlank(), then place the cursor between parentheses and click the Collapse Dialog button in the right-hand part of the window to select a range of cells, or you can type the range manually, e.g.
=IsBlank(B2:H12)
. - Click the Format… button and choose the needed background color on the Fill tab (for detailed instructions, see step 5 of "How to dynamically change a cell color based on value") and then click OK.
The preview of your conditional formatting rule will look similar to this:
- If you are happy with the color, click the OK button and you'll see the changes immediately applied to your table.
Change the background color of special cells statically
Once changed, the background color will remain the same, regardless of the cell values' changes.
If you want to change the color of blank cells or cells with formula errors permanently, follow this way.
- Select your table or a range and press F5 to open the "Go To" dialog, and then click the "Special…" button.
- In the "Go to Special" dialog box, check the Blanks radio button to select all empty cells.
If you want to highlight cells containing formulas with errors, choose Formulas > Errors. As you can see in the screenshot above, a handful of other options are available to you.
- And finally, change the background of selected cells, or make any other format customizations using the "Format Cells" dialog as described in Changing the background of selected cells.
Just remember that formatting changes made in this way will persist even if your blank cells get filled with data or formula errors are corrected. Of course, it's hard to imagine off the top of the head why someone may want to have it this way, may be just for historical purposes :)
How to get most of Excel and make challenging tasks easy
As an active user of Microsoft Excel, you know that it has plenty of features. Some of them we know and love, others are a complete mystery for an average user and various blogs, including this one, are trying to shed at least some light on them. But! There are a few very common tasks that all of us have to perform daily and Excel simply does not provide any features or tools to automate them or make an inch easier.
For example, if you need to check 2 worksheets for duplicates or merge rows from single or different spreadsheets, it would take a bunch of arcane formulas or macros and still there is no guarantee you would get the accurate results.
That was the reason why a team of our best Excel developers designed and created 70+ add-ins that we call the Ultimate Suite for Excel. These smart tools handle the most grueling, painstaking and error-prone tasks in Excel and ensure quickly, neatly and flawless results. Below is a short list of just some of the tasks the add-ins can help you with:
- Remove duplicates and find unique values
- Merge tables and combine data from different sources
- Combine duplicate rows into one
- Merge cells, rows and columns
- Find and replacing in all data, in all workbooks
- Generate random numbers, passwords and custom lists
- And much, much more.
Just try these add-ins and you will see that your Excel productivity will increase up to 50%, at the very least!
That's all for now. In my next article we will continue to explore this topic further and you will see how you can quickly change the background color of a row based on a cell value. Hope to see you on our blog next week!
426 comments
Lets say I have a formula in a cell from another page in the workbook. The cell in the other work book is a drop down. Is there any way when that drop down is used/filled to make the cell on the second page change color to show its populated?
Hello Steph,
It looks like you need a special macro to fulfill this task. I am really sorry we can't help you with this.
Thank you, this topic is helpful
Is there a way to format a column of numbers to highlight only when another column has an "X" in that row?
Hi Patricia,
Of course, there is a way. Simply select the column you want to highlight, not including the header and create a rule for it with this formula:
=A2="X"
Where A2 is the first cell with data in the other column, again not including the header row.
You're the best! Thank you doll
Dear Svetlana Cheusheva,
Can we color a cell based on result. In detail, I am using a formula (=min(various nos of cell in a particular row) to find the lowest figure , Like ( =MIN(W7,S7,O7,K7,like so on))and for example result is W7 cell and I want to automatically color the W7 cell. By conditional formatting it can be done by selecting entire cell range, but problem is I have to more than 40-50 row and I have to repeat the same rule for each row. Is there any help for me. Pls guide.
Hello Rameswar,
You can select all the rows and create the conditional formatting rule with the formula =A7=MIN($W7, $S7, $O7....)
Where A7 is the first (top-left) cell of your range.
But I'd recommend creating a helper column (hidden) and copy the following formula there: =MIN($W7, $S7, $O7....) And in your conditional formatting rule, use the formula =A7=$AB7, where A7 is the top-left column and AB is the helper column.
If you have a large data set, this rule will work much faster because Excel won't have to calculate =MIN($W7, $S7, $O7....) for each cell where the rule is applied.
Thank you for your response, but i might not have explained it well enough.
I have 3 cells that need to change rules according to what i have selected from a drop down list. So, if i have "refrigerator" selected from the list, the 3 cells need to have one rule for that selection, and if i select "freezer" the same 3 cells need to have another set of rules. Not sure how to do it.
Thanks for you help though! :)
Hi Ron,
Regrettably, Excel conditional formatting rules cannot be changed depending on the value selected in the drop down list (this can be done using VBA only).
As an alternative, you can create several rules for the same range of cells, one per each value in the drop-down list, that will check the contents of your drop box and color the cells you want depending on the drop-down list's value and your additional conditions.
Hi,
Can I have a complete row highlighted in any color based on if there is any change (addition or deletion) of data from the exiting value?
Hi Rohit,
You can apply a conditional formatting rule to entire rows. Please see this tutorial for more details - How to change the row color in Excel based on a cell’s value. To be able to suggest a formula, I need more info about your data structure and the result you are looking for.
very nice , thank you.
Please Please Help!!!
My cell C1 has to say "yes" if A1>100 and B1100 and B1>70.
please help how to make this formula ??? My head is broken by now :(
Hi Sergey,
Here you go :)
=IF(AND(A1>100, B1100>70, B1>70),"yes","")
I am creating a task list and I would like to change the fill color of the row depending on to whom the task is assigned. I have created the drop-down list and used conditional formatting to assign colors to the individuals names. Now when I select a name from the drop-down list the fill color changes for that cell. How can I get the corresponding cells in the row to change to the same color?
Hello John,
You just need to apply the rule you created to the entire rows. Please see this tutorial for full details - How to change the row color based on a cell’s value in Excel.
Thank you for taking the time to assist me. It is much appreciated.
i want to color some cells based on different cell's condition. I've done it but the problem is when i close the document after saving and open again then i see that the condition has been erased. but why??
Hi Tanjin,
This is absolutely abnormal! Please make sure you save the workbook after creating the rule.
Sorry, i meant color coded values
Hi Ron,
You can select a group of sells you want to color (e.g. D10:D12) and create 2 rules with different fill colors based on these formulas:
=$D10="Refrigerator" and =$D10="Freezer".
How can you make a group of cells change their rules based on what you select from a drop down list??
I have a drop down list consisting of "Refrigerator" and "Freezer". I have coded values in "D10-D12" that need to change based on whether i have "freezer" or "refrigerator" selected.
Thanks!
Hai,
I have a trend monitoring datasheet . Each kind of trend refers to 1 - 100 numbers. i need to highlight the trend if it occurs more than 2 times.
Eg. Trend No.1 - BY Road, 2 -By shop, 3 -By School ... up to 100 numbers. If trend No.1 occurs two times, it should highlight. Can you please help me.
Hi Anil,
To be able to suggest a proper formula, I need to know more details. Is each trend a column or a row? Do you want to highlight certain cells or entire rows? Please send me a workbook with your sample data at support@ablebits.com and I will try to help.
Hi,
I want to change the cell colors in col A based on the values in another cells say Col C. Here, i have conditions that if the values in Col C are in the range <% then green, if + % then yellow otherwise Red..how to get it done!!
Hi!
You can select all cells with data in column A, not including the column header, and create 3 conditional formatting rules based on the formulas like these (assuming that row 2 is your first row with data).
Green: =$C2<50%
Yellow: =$C2>60%
Red: =AND($C2>=50%,$C2<=60%)
For more details, please check out this tutorial: How to change a cell’s color based on another cell.
I am working with recertification dates of about 100 people. I have columns with recertification dates with an adjacent column that allows me to see if personnel are current or overdue. These cells change color based on that value. Their are several columns of data between the name of the indivual and their status. I would like to highlight names of individuals who are overdue. Is there a way to reference another cell so that when they go overdue it highlights their name and when they return current the highlighting goes away?
Hello Matt,
You can do this by creating a conditional formatting rule based on a formula. Select the column you want to highlight a create a rule using a formula similar to this: =$C2="Overdue" (where C is your status column and 2 is your 1st row with data). You can find more information about conditional formatting based on another cell here: Change a cell’s color based on another cell value.
Hi Svetlana,
I am struggling to figure out how to set a value range in my spreadsheet to correlate with specific colors when a value is input in the cells. For instance, I want the cell color to be blue when the value input into the cells is less or equal to 2.0, and if the value is 3.0 - 4.0 the cell will turn green, and if the value input into the cell is greater than or equal to 4.1 it will turn pink. Can you please help?
Thank you in advance for any assistance you can provide.
Julie
Hi Julie,
You can easily do this by creating 3 separate rules in this way:
- Select all the cells you want to color;
- Click Conditional Formatting > New Rule > Format only cells that contain;
- Select the needed option from the drop-down list (2nd box from the left) for each rule - "less or equal to", "between", and "greater than or equal to";
- Click the Format button and choose the format you want for each rule.
You can find the detailed guidance with screenshots here - Creating an Excel conditional formatting rule. Hopefully you will find the info helpful.
This has been so very helpful. Thank you for sharing your wealth of knowledge. I would love to know how to conditionally format a cell colour based on whether a different cell is NOT blank. I have perfected the blank value, how do I do the opposite?
I am also curious if it is possible to use the icon sets to show based on the value (or the blank versus containing data) of other cells. An example, a check list of items that spans a row, a check mark at the front of the row to show all columns have been filled in (contain data, any data) or an exclamation in the first cell to show that there are some cells that are blank, or an x if all cells in that row are blank. Is that even possible???
Thank you for your time
Hi Michelle,
You can create a rule with the following formula: =$B2="" It will color cells in the selected column(s) if a corresponding cell in Column B is not blank. Naturally, you will need to replace B with the column you need, and "2" with the row number where your data starts.
As for the icon sets, I described a solution exactly for this task in my latest article - How to use conditional formatting in Excel. You can go directly to the section How to apply an icon set based on other cells' values. Hopefully, this is what you are looking for.
Oh my gosh that icon set creativity is brilliant!!! Thanks Svetlana!!
thanks for supporting
How to change colour of entire column ( if > green &if < red)comparison to other column ?
Hello Rasendra,
This is a bit unusual to change the color of the entire column, most other users asked how to change the color of the entire row. Anyway, if this is your task, you can change the color of the whole column in this way:
- Select the entire column, say column B.
- Create 2 rules with these formulas: =$B$2<$A$2 and =$B$2>$A$2 (we are comparing values in row 2).
Make sure both formulas are applied to the entire column, say =$B:$B.
Hi, never mind previous request, I found the answer in another of your articles. Also very good, by the way.
Thank you for your feedback Justine! I am really glad to know you found the articles helpful.