Written by Allen Wyatt (last updated March 18, 2020)
This tip applies to Excel 2007, 2010, and 2013
Andre has a table of data that includes some conditionally formatted cells in column M. The formatting is based on conditions in cells of the same row in columns G and H. When he sorts the table, the conditional formatting seems to stay with the original row. Thus, if the original cell was M10 (tied to cells G10 and H10), after the sort the cell ends up in M7, but it is still tied to G10 and H10. It should, instead, now be tied to G7 and H7. Andre wonders how he can get Excel to sort his conditional formatting references properly.
This problem is most likely related to how your referencing is done in your conditional format rules. Typically, when you reference cells when setting up a rule, Excel defaults to absolute referencing. In other words, your rule may look something like this:
=AND($G$10=1, $H$10=1)
The dollar signs indicate that whatever follows (either the column reference—G or H—or the row reference—10) is absolute and should not be modified by Excel. This means that when the rows are sorted, the references in the rules are not modified and they will still point to the original rows. If you want the references to change, then you'll need to modify the rules to remove the dollar signs before the row references:
=AND($G10=1, $H10=1)
It is not necessary to remove the dollar signs from the column references because your sorting isn't modifying those column references.
If you are still running into problems with the rules after sorting, it is possible that not all your data is getting included in the sort. This is particularly true if you leave it up to Excel to select your data table automatically for the sorting operation. Make sure you select the entire data table before sorting and this should solve the problem.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9951) applies to Microsoft Excel 2007, 2010, and 2013.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
When you paste information into a row that is conditionally formatted, you may end up messing up the rules applied to ...
Discover MoreConditional formatting is a great tool for changing how your data looks based on the data itself. Excel won't allow you ...
Discover MoreComparing values (like is done in conditional formatting rules) can yield some crazy results at times. This tip looks at ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2019-03-29 09:26:57
Thomas Morris
Hello, I have followed your instructions but when I remove the rows ($) sign Excel puts them back when I hit apply. Thanks, Thomas Morris
2015-04-20 08:40:58
Simon Graffe
The proposed solution does not work.
The conditional format applies to "$M$10" and there is no way to change it, so the rule reads:
Formula: =AND($G10=1, $H10=1)
Applies to: =$M$10
Sort the data, open the Manage rules dialog box, and the rule reads exactly the same. So, when your data is in row 7 after the sorting, it will not be formatted.
The "Applies to" box could be changed to: =$M$7:$M$100 (include all data in column M) and the rule will apply to all the column, and it will appear it is working, but the original problem asked for SOME rows to be conditionally formatted, not ALL of them.
The solution would be to add some specific data to the row, and include it in the formula. That specific row data would be sorted along with the data, and the rule will work.
This solution works:
Formula: =AND($C7="Format10", $G7=1, $H7=1)
Applies to: =$M$7:$M$13
In this case, the data rows include rows from 7 to 13. The formula refers to the first row (7) of data, and the Applies to formula refers to the M column, not just one cell. The "Format10" value should be added at column C to the row that should be formatted.
2015-04-18 08:05:41
Sicco Jan Bier
When you create a reference, it pays off to toggle and connect the absolute cell reference with F4. It will suggest absolute, row, column and relative reference when you hit F4 repeatedly.
Using defined names for ranges is another way to make the reference fixed, while keeping all elements within the range available (depends on the formula to use). Especially for lists and lookups.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments