Exploring Data in Excel with Conditional Formatting

Conditional formatting is a hidden gem in Excel. It's fairly easy to use, works well, and doesn't get in your way. Here's how we use it to assist in data exploration.

Conditional formatting is found in the Format menu. Most people are probably familiar with using it this way:

Basic conditional formatting

These settings would make any cells with a value greater than 30 have a bright red background. So far, so good.

However, you can do many more powerful things by setting the condition to a formula that is either true or false. For instance, in the dashboard that I created to show the in-cell bar charts, I use a formula like this:

Conditional formatting using the percentile function

This formula compares the value in the cell to the 75th and 25th percentiles of the data in the cells column. If the value is greater than the 75th percentile, use a green font color, if the value is less than the 25th percentile, then use a red font color. The percentiles update automatically with your data.

To get this to work, you need to be mindful of your relative and absolute references. The cell reference on the left hand side of the formula is relative, but the percentile column reference is absolute in rows. This allows you to copy this formula around while maintaining the appropriate ranges. When you start entering formulas for conditional formats, Excel defaults to use absolute references, which doesn't give you the flexibility you need. You'll have to edit the formulas by hand.

Here's another useful case. Sometimes you need to shade alternate rows to make a table more readable. But if someone sorts the table, your shading sorts too. Conditional formatting is an elegant solution and it doesn't even mess with the relative/absolute cell references.

Alternating shading with conditional formatting

The formula =ROW()=EVEN(ROW()) is easy to understand once you know what these obscure functions do. =ROW() returns the row of the current cell. =EVEN(...) rounds some number to an even number. Thus, if ROW() is an even number, the formula is true, and it's false on odd numbered rows.

This last trick is what I use most often. Sometimes you have a very large amount of data that is divided into records with multiple rows per records. Consider something like sales records per customer. You'd like to break this data into chunks—by customer, for instance—as you scan through it.

This conditional format puts a line below each row whenever a particular column value changes.

Displaying a line whenever a value in a column changes

The function is quite simple. If column D has changed, then place a line above the row. However, you do have to be quite careful about relative vs. absolute formatting.

Here is a spreadsheet that contains all the examples discussed above for you to explore.

Excel conditional formatting tips.xls

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. All source code is released under a BSD License unless otherwise specified.

111 comments | Show all comments only the last 5 are shown


July 23, 2008
Debbie said:

Hi I use conditional formatting to highlight cells that have values larger than the previous column. This applies to 6 consecutive columns, across a range of rows (e.g. =(V73:V110)<(W73:W110), =(W73:W110)<(X73:X110) for the next column, and so on). However, the row numbers keep shifting on their own, even though I am certain that I have keyed in the correct rows. What am I doing wrong?


January 23, 2010
John said:

I LOVE excell but am only recenlt getting aquainted with the myriad of miracles it can perform. Question: does the value in a cell have to be typed in as an actual value or can it reference the result of a formula in that cell which would be a whole number. For example, I am trying to build page folios that would appear in a cell above a rectangular page like cell. The cell with the folio in it, reference another cell that has the total number of pages you want to appear. So, for instance, if I type 12 in the referenced cell, the first 12 cells reference numerically by a formula (=if(A1>=8) meaning the number * would appear in a cell as a page folio. But I also want to conditionally format that cell so that is become yellow when a page number appears in the cell but is clear (white) when that cell does not have a folio in it. I've tried several conditonal formats. None seems to work. Can anyone help me?


April 12, 2010
Lorraine said:

Can anyone help me to use the conditional formatting where I have mutliple rows of data that I need to separate with a bold line as described above? The difference is that the only way I have of identifying where is that 3 columns will change from having blank cells in the row above to ones with data in below. It's probably obvious .....


June 7, 2010
Tim said:

I have an estimating template that I need to write a formula for. If a cell is linked to any other cell the the font needs to be black. If the cell is a hard entered number the font needs to be blue. Is there a formula to achieve this?


July 23, 2010
Jono said:

I'm trying to get a cell to conditionally format based on the sum of numbers. There is a list that is all numbers and changeable T6:w30. I would like it to SUM them up and then highlight a specific cell Yellow if they add to an Odd number and Green if they add to an Even number. Is this possible?

Your name

Email (optional, will not be shared)

Type the word "juice" (required to confuse the spammers)

Your comment


Add a comment