Excel 2010 Conditional Formatting Nightmare

Excel 2010 Conditional Formatting Nightmare

[Updated June 2018] I’m a big fan of Excel’s conditional formatting, and often use it to highlight cells on a worksheet. But this week I ran into a conditional formatting nightmare, and had to start from scratch. Fortunately, the fix didn’t take too long, but with complex formatting, things could have been much worse.

Separate the Dates in a List

There are lots of ways to use Excel conditional formatting. It’s useful for alerting people to problems, hiding duplicate values in a column, or even hiding cells’ contents, until related cells are filled correctly.

Earlier this year, I posted a tip for separating dates in a list, by using a red border at the start of a date change.

ConditionalFormatSections04

Easier to Read

It’s a technique that I use in one of my own workbooks, which I update every morning. The red border really makes the list easier to read, especially if I’m looking at it before my morning coffee!

The conditional formatting was set for cells A2:F9, and uses a simple formula to see if the date is equal to the date in the row above.

ConditionalFormatDuplicate01

Quick Copy and Paste

In the workbook, I track some daily statistics for my website, and use the same headings every day. So, to save typing time, I copy and paste the headings from the day before.

For example, in the screen shot above, I could copy the regions and products headings from B2:C4, and paste them into cell B10:C12, for the latest day’s data.

ConditionalFormatDuplicate02

The Excel table automatically expands to include the new rows, and fills in the formulas in column F. Awesome!

And that copy and paste trick is what I’ve been doing every day, for months on end.

Trouble With the Lines

Suddenly, this week, I started having trouble with the red border between dates – it wasn’t going across the full table.

So, I went into the Conditional Formatting Manager, to fix the problem. But, instead of one simple rule, there were hundreds of rules!

You can see the tiny scroll box at the bottom right in the screen shot below. That should give you some idea of how long that list was.

ConditionalFormatDuplicate04

Every time that I copied and pasted within the conditional formatting range, it created another rule for the worksheet. Yikes!

Let’s take a look at the smaller example, where I just copied and pasted the Region and Product headings. Now, it has two rules, instead of one, after one copy and paste within the table.

ConditionalFormatDuplicate05

Cleaning Up the Mess – UPDATED

UPDATE – March 2017: I’ve found a quicker way to fix the problem, as you can see in this video. Get the detailed steps on my Conditional Formatting page.

There is a full transcript of the tutorial following the video.

TRANSCRIPT FOR THE VIDEO

Conditional Formatting

In this workbook, I’ve got a couple conditional formatting rules, and I’m going to show you how those can get duplicated, so you end up with lots more rules than you started out with, and then how you can fix the problem.

So in this table I have two rules. 

–One puts a line at the top of a date, if it’s different from the date above.

–The other rule changes the price to green, if it’s greater than $500 dollars.

We’ll take a look at those rules. In the Home tab, go to Conditional Formatting, Manage Rules.

And there you can see the two rules. They’re each applied from row 3 to 19 in this table.

–Now this one is just a cell value greater than 500. 

–And this one is referring to a couple of cells. So if A2 is different from A3, we’re going to put a blue line, at the top of the cell.

How Problems Happen

And now, I’m going to insert a row, because I forgot to put in one of the records here. So I’ll click, Insert. And then just put some data in this row.

So that was a simple change to the table. And now I’m going to go back and look at my conditional formatting rules again. And suddenly I have a new rule, just for the row that I inserted. 

So row 11 has its own rule, and the previous rule is still there, going from A3 to E10, and then A12 to E20. So it’s skipping this row, because that row has a separate rule.

And if you insert lots of rows, you can end up with hundreds of these rules set up, without even knowing it.

The Solution

And what I do to fix it is select all the rows, except for the first one. Then go to Conditional Formatting, Clear Rules, From Selected Cells.

Now if I go back in, and Manage Rules…I’ll go back to This Worksheet, just so we can see everything. So we’re back to those two original rules.

Then, I select the first row. I’ll select the first row in the table, this time, instead of the whole worksheet.

And go to the Format Painter, and make sure you’re selecting this first row as well, and apply that formatting to all the rows again.

And when we go back to Manage Rules, we still just have those two original rules.

If you need to do this frequently, go to my website to get a macro that removes the duplicate rules. It’s designed for data in in an Excel named table.

End Of Transcript

The previous solution is listed below, in case you’d rather try that.

Cleaning Up the Mess – ORIGINAL SOLUTION

I scrolled through the list, and deleted a few of the rules, but quickly realized that it would take far too long to delete all of them. So, to clean up the mess, I cleared the conditional formatting from the worksheet, and set it up again.

ConditionalFormatDuplicate06

With all the extra rules gone, the conditional formatting borders were working correctly again.

Avoid Conditional Formatting Nightmare

Now, when I want to save some typing time in the daily list, I copy the previous headings, and use the Paste Values button to create the new records. I’ve got a copy of that button on Excel’s Quick Access Toolbar, so it’s easy to click.

ConditionalFormatDuplicate07

That adds the text, and the table expands, including the formulas – but the conditional formatting doesn’t create a new rule.

Be careful out there — don’t let this conditional formatting nightmare happen to you!

Another Solution

Update: Thanks to Khushnood, who suggested leaving 3 blank rows at the bottom of the table, and inserting new rows above that, when adding new data.

Copy and pasting within the table doesn’t seem to produce the duplicate conditional formatting.

It’s still an extra step though, instead of a simple copy and paste.
________________

83 thoughts on “Excel 2010 Conditional Formatting Nightmare”

  1. My issue with conditional format is copy and paste.
    Currently setting up data base where i have to highlight stock based upon min/max ranges.
    i.e. D7 is min stock, E7 max stock, F7 is stock on hand.
    F7 shall highlight red if over Max level or Yellow for under stock levels and no highlight for in stock range.
    That’s done.. so now instead of doing this 500 times.
    I follow the format painter way or try copy paste (formula) down from F7 down to F30 for test.
    It look great yet all F colum reading from D,E7 regardless if they in cell F30.
    They not reading from F30 or the row they assigned too..
    I don’t want do every single line by line action…

  2. I have found a way that seems to avoid the adding additional rules when you insert a new row within a range to which conditional formatting is applied.
    1. Insert the new row.
    2. Copy the row above it (or I imagine any row within the originally defined range).
    3. Use “Paste Special” and select the option that says: “All, merge conditional formats”.
    Let me know if it works consistently for you.

  3. I’m using MSO365 and I love conditional formatting (c/f) and use it for a huge variety of reasons and have many. So, once a week, while doing my backup routine, I make a copy of the sheet with all the c/f on it, go to the original and clear all formatting. Then I select one cell in the 1st column – eg A4 (I have 4 columns with c/f in it, most of the rules applying to more than one column), press ctrl-c, go to the original sheet, select the whole column A and click paste formatting (which I’ve put on my Quick Access toolbar). I obviously delete the duplicated sheet once I’m done.
    Sounds tedious but it goes quick and has proven not to drive me insane.
    I have asked MS to work on their c/f feature for years now. When working in the C/F Rules Manager, one cannot make the space to work in any bigger and are confined to that small claustrophobic window. Also one can’t hi-light your “applies to” rule info and paste over it. You have to hi-light, delete and then paste. These are just two of a few things they can hugely improve on.
    Still a brilliant feature which I don’t think I could work without anymore, so I continue to work around it’s shortcomings 😀
    Thanks for your tips and tutorials.

  4. I agree with what has been posted previously; copy and paste values (or paste formulas) will totally work to not split up the conditional formatting.

    I’m a little lazy for that. And I don’t want those who use my spreadsheets to have to do that. I’m also not confident that they will remember to do copy and paste values. 🙁

    I don’t know if this solution will work for your needs, but I resorted to deleting all conditional formatting and reapplying the correct conditional formatting every time the workbook is opened.

    Because this macro runs every time the workbook is opened, the user does not need to change the way they copy and paste. They don’t need to know that the macro is even there. They don’t need to manually run the macro; it is automatic. I feel this creates a better user experience.

    Please keep in mind that this code needs to be copied and pasted into the “This Workbook” module; not a regular module.

    Private Sub Workbook_Open()
    ‘This will delete all conditional formatting and reapply the conditional formatting properly.
    ‘After copying and pasting the conditional formatting get split into two or more conditional formattings. After a few
    ‘weeks there are so many conditional formattings that Excel crashes and has to recover.

    Dim ws As Worksheet, starting_ws As Worksheet

    Set starting_ws = ActiveSheet ‘remember which worksheet is active in the beginning
    Application.ScreenUpdating = False
    For Each ws In ThisWorkbook.Worksheets
    If ws.Name “InvErr” Then
    ws.Activate
    Cells.FormatConditions.Delete
    ”Every Other Row Tan
    Range(“A4:M203″).FormatConditions.Add Type:=xlExpression, Formula1:=”=ISODD(ROW(A4))”
    Range(“A4:M203”).FormatConditions(Range(“A4:M203”).FormatConditions.Count).SetFirstPriority
    Range(“A4:M203”).FormatConditions(1).Interior.PatternColorIndex = xlAutomatic
    Range(“A4:M203”).FormatConditions(1).Interior.ThemeColor = xlThemeColorDark2
    Range(“A4:M203”).FormatConditions(1).Interior.TintAndShade = 0
    Range(“A4:M203″).FormatConditions(1).StopIfTrue = False

    ”Highlight Duplicates Red
    Columns(“B”).FormatConditions.AddUniqueValues
    Columns(“B”).FormatConditions(Columns(“B”).FormatConditions.Count).SetFirstPriority
    Columns(“B”).FormatConditions(1).DupeUnique = xlDuplicate
    Columns(“B”).FormatConditions(1).Font.Color = -16383844
    Columns(“B”).FormatConditions(1).Font.TintAndShade = 0
    Columns(“B”).FormatConditions(1).Interior.PatternColorIndex = xlAutomatic
    Columns(“B”).FormatConditions(1).Interior.Color = 13551615
    Columns(“B”).FormatConditions(1).Interior.TintAndShade = 0
    Columns(“B”).FormatConditions(1).StopIfTrue = False
    End If
    Next

    starting_ws.Activate ‘activate the worksheet that was originally active
    Application.ScreenUpdating = True

    End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.