Conditional formatting and Tables

Copper Contributor

I have a table with conditional formatting set. When I add info to the bottom the table expands and so does the conditional formatting.

 

When I insert a row into the middle of the table however, The formatting seems to expand, but it does so by creating more formatting rules.

 

Such as:

Applies to - $A$1:$A$100 turns into

$A$1:$A$89 and $A$90 and $A$91:$A$101

This makes for a larger, messier list of Conditional formatting rules. 

 

Is there a way to get around this to keep it cleaner? I use Office 2016, do upgraded versions not do this?

 

Thank you!

12 Replies

Hi @kevin_serenity 

 

My Excel 365 doesn't do it  (I'm not convinced it used to happen with older versions either)

 

If I insert a row then copy and paste down the row above it does happen

 

How are you inserting the row?  And are you doing any copy pasting after inserting the row

 

Wyn

MVP

@Wyn Hopkins 

There is a Copy-Paste-Special option that allows you to merge rather than duplicate the conditional formats, but I don't think it gets invoked with Table additions

CharlesDecisionModels_0-1611228952038.png

 

@Wyn Hopkins 

Wyn, it still inserts extra rules if references in rule formula are out of applied range, like in this case - formula uses S4 but range starts from S5.

@Wyn Hopkins My usual way is to right click on the row 'below' where I want to insert a new row. For example, if there is data for John Doe in row 80 and I want to add another line item for John Doe directly below that. I right click on row 81 and select 'insert' then I can copy paste values in there, or just enter them manually so John's data stays together. All my formulas in the sheet work and the cond formatting "works" as well... but as shown the cond formatting creates new rules to do this as opposed to just extending the range like I think it should to reduce the amount in there. This doesn't happen when the table expands by copying data at the bottom.

 

I looked at some other sheets I made too and they have been doing the same thing.

@Sergei Baklan It assure you this is not the case. I just went in and deleted that rule to check and when I inserted a row it did the same thing.

@kevin_serenity 

Just in case, could you please share rule formula?

@Sergei Baklan 

Here's a couple of them, pretty basic rules

=$AA6<>"" applies to =$AA$6:$AA$93

=AND($E6="",$F6="") Applies to =$E$6:$F$93,$U$6:$Y$93

 

These I used to indicate if two opposing numbers cancel each other out

=AND($T6<>"",$T7<>"",$T6=$T7*-1) Applies to =$T$6:$T$93

=AND($T5<>"",$T6<>"",$T5=$T6*-1) Applies to =$T$6:$T$93

 

I feel like the issue only has to do with the 'applies to' part and inserting a row into the middle of the table makes excel do a kind of workaround to get it to apply to the whole range. Very strange though

@Sergei Baklan 

...actually you might be right. I deleted the two formula rules that had to do with matching one row to another. Once I inserted another row that didn't affect any of the other rules in the sheet.

@kevin_serenity 

Thank you for the formulas. Instead of $T5<>"" you may use something like =OFFSET($T6,-1,0)<>"". I didn't test but perhaps that could help.

@kevin_serenity 

 

I'd recommend "surfacing" any slightly complex conditional formatting formulas into the table itself if at all possible (you can then use the Group option to hide these helper columns)

 

Easier to debug that way.

 

image.png

 

Also I tried to avoid Offset.  Although it is a nice suggestion from Sergei

Personally I'd use this  (more complex but not volatile)

 

=IFERROR(   [@item] = INDEX([item], ROW([@item])-ROW(Table1[[#Headers],[item]])+1), "")

image.png

@Wyn Hopkins , I agree, it's always better to avoid volatile functions. On the other hand it depends on situation. OFFSET() is more user-friendly. Depends on workbook and my skills I may save few milliseconds on recalculations but lose hours on solution development and its maintenance.

I have exactly the same issue. I have Office 365 and none of the solutions here solved the issue.