Jan 20 2021 08:24 AM
Jan 20 2021 08:24 AM
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.
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?
Jan 21 2021 02:18 AM
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
Jan 21 2021 03:36 AM
Jan 21 2021 06:03 AM
@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.
Jan 21 2021 07:47 AM
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
Jan 21 2021 05:14 PM
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.
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), "")
Jan 23 2021 06:38 AM
@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.