The black arrow indicates the direct relationship between the top-left cell and the cell reference, while the gray arrows indicate the implied relationships that are formed as a result. The cells with blue borders indicate the range to which this CF rule is applied, the bold blue border is used to illustrate the top-left most cell in the CF range and the red border shows the cell referenced by the CF formula.
The diagrams below are examples of how to setup two commonly used CF rules – row and column comparisons. Hence, all the other cells in the range were compared with the cell to their left. In our case, the top-left cell C2 was compared against the cell to its left (B2). To simplify things, I like to pretend as if I have only selected the top-left most cell and I am writing a formula in that particular cell. In conditional formatting rules, cell references are relative to the top-left most cell in the Applies to range. How Relative References work in CF Rules? For example, let us add information about a new branch in Boston. And there’s more, the rules automatically adjust to if new rows are added in the middle of this range. We get exactly, the same result as before. TIP: you can use the F4 key to cycle through different types of relative references until you get B2 without the $ signs.Īnd there you have it we have just one Conditional Formatting rules where every cell’s value is compared. However, this time we use change the reference to be a relative reference (B2). When the Less Than dialog pops up, we again select the cell B2 to get an absolute reference ($B$2).
To do this, select the entire range of cells to which you want to apply the rule (in our example: C2:F6) and click on “Conditional Formatting -> Highlight Cell Rules -> Less Than” on the home tab. There is an easier way to do this by using just one Conditional Formatting Rule applied to the entire range.
Relative References – using a single Conditional Formatting Rule Besides having to edit multiple rules for any changes, the rules won’t adjust if you insert a new row or column. – Difficult to Maintain: Such rules are hard to maintain. – Performance hit: Having lots of individual conditional formatting rules can degrade performance. Besides being a tedious task (users often automate such tasks by using subroutines), there are other problems with this approach: This small table consists of as many as 20 individual rules – each comparing the cell’s value to its neighbor on the left. To perform column comparisons in this fashion, the user ends up having to create a new rule for each cell and select the neighboring cell for comparison. Notice that the value is the dialog gets replaced by an absolute reference to cell B2 ($B$2). When the Less Than dialog pops up, we select the cell B2 against which we want to compare. In our example, we select cell C2 and click on “Conditional Formatting -> Highlight Cell Rules -> Less Than” on the home tab. Tedious Way – Lots Individual Conditional Formatting Rulesįor complex conditional formatting rules, users often get around that problem by creating lots of individual rules applied to single cells. When absolute references are used in conditional formatting rules, every cell to which the conditional formatting rule is applied is compared to that single referenced cell. (ExcellsFun has a great video that explains relative and absolute cell references). By default, conditional formatting inserts an absolute reference when we select another cell as a reference. Let’s say we want to highlight the cells where sales have decreased compared to the previous year. In this blog post, we will learn how to use relative references in conditional formatting rules to make such tasks easier.įor example, consider the spreadsheet below where we have sales data for different branches of an organization over the years 2005 to 2009: However, users often want to create conditional formatting rules that go beyond comparing a cell’s value to a single value or a single cell reference – row or column comparisons are commonly requested operations.
This is the second in a series of oldies but goodies Excel posts.)Ĭonditional formatting is a popular feature and is a great way to easily identify cells with a range that meet some criteria. Why? Because so many of you keep searching for it. (We are re-publishing this post first published in April 2010. Thanks to Amit Velingkar for writing this blog post.