Top Banner
In this article, you will find two quick ways to change the background color of cells based on value in Excel 2013, 2010 and 2007. 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. Change the background color of cells based on value (dynamically) - The background color will change automatically when the cell value changes. Change a cell's color based on its current value (statically) - Once set, the background color will not change no matter how the cell's value changes. Change color of special cells (blanks / with errors / with formulas) 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 orbetween 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 2007 and Excel 2013. Okay, here is what you do step-by-step:
14

How to Change a Cell's Color

Sep 20, 2015

Download

Documents

Skydriver Paul

How to Change a Cell's Color
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

In this article, you will find two quick ways to change the background color of cells based on value in Excel 2013, 2010 and 2007. 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. Change the background color of cells based on value (dynamically)-The background color will change automatically when the cell value changes. Change a cell's color based on its current value (statically)-Once set, the background color will not change no matter how the cell's value changes. Change color of special cells (blanks / with errors / with formulas)How to change a cell's color based on value in Excel dynamicallyThe 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 valuesgreater than X,less than Yorbetween 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 2007 and Excel 2013.Okay, here is what you do step-by-step:1.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).2.Navigate to the Home tab, Styles group, and chooseConditional Formatting>New Rule....

3.In theNew Formatting Ruledialog box, select "Format only cells that contain" under "Select a Rule Type" box in the upper part of the dialog box.4.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 aCell Value - greater than - 3.7, as you can see in the screenshot below.

Then click theFormat...button to choose what background color to apply when the above condition is met.5.In theFormat Cellsdialog box, switch to theFilltab and select the color of your choice, the reddish color in our case, and clickOK.

6.Now you are back to theNew Formatting Rulewindow and the preview of your format changes is displayed in thePreviewbox. If everything is Okay, click theOKbutton.

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 theNew Rulebutton 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 theOKbutton. 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 tochange the font color based on the cell's value. To do this, simply switch to theFonttab in theFormat Cellsdialog box that we discussed instep 5and choose your preferred font color.

How to permanently change a cell's color based on its current valueOnce set, the background color will not change no matter how the cell's contents might change in the future.Task: You want tocolor 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'sFind Allfunction orSelect Special Cellsadd-in, and then change the format of found cells using theFormat Cellsfeature.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 conditionThere may be several possible scenarios depending on what kind of values you are looking for.If you need tocolor cells with a particular value, e.g. 50, 100 or 3.4, go to theHometab,Editinggroup, and clickFind Select>Find....

Enter the needed values and click theFind Allbutton.

Tip: Click theOptionsbutton in the right-hand part of theFind and Replacedialog 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 theFind and Replacedialog window by clicking on it and then pressCtrl+Ato select all found entries. After that click theClosebutton.

This is how you select all cells with a certain value(s) using theFind Allfunction in Excel.However, what we actually need is to find all gas prices higher than 3.7 and regrettably Excel'sFind and Replacedialog does not allow for such things.Luckily, there is another tool that can handle such complex conditions. TheSelect Special Cellsadd-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 theSelect by Valuebutton 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 theSelectbutton and in a second you will have a result like this:

If you are interested to try theSelect Special Cellsadd-in, you can download an evaluation versionhere.Change the background color of selected cells using "Format Cells" dialogNow 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 theFormat Cellsdialog by pressingCtrl+1(you can also right click any of selected cells and choose "Format Cells..." from the pop-up menu, or go toHome 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 theFill colorbutton 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 cellsA 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.1.On theHometab, in theStylesgroup, clickConditional Formatting>New Rule...(see step 2 ofHow to dynamically change a cell color based on valuefor step-by-step guidance).2.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 a range selection iconin 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).

3.Click theFormat...button and choose the needed background color on theFilltab (for detailed instructions, seestep 5of "How to dynamically change a cell color based on value") and then clickOK.The preview of your conditional formatting rule will look similar to this:

4.If you are happy with the color, click theOKbutton and you'll see the changes immediately applied to your table.

Change the background color of special cells staticallyOnce 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.1.Select your table or a range and pressF5to open the "Go To" dialog, and then click the "Special..." button.

2.In the "Go to Special" dialog box, check theBlanksradio button toselect all empty cells.

If you want to highlight cells containingformulas with errors, chooseFormulas>Errors. As you can see in the screenshot above, a handful of other options are available to you.3.And finally, change the background of selected cells, or make any other format customizations using the "Format Cells" dialog as described inChanging 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 :)