Excel - Conditional Formatting - insert row

前端 未结 16 1581
轮回少年
轮回少年 2021-01-01 11:37

Using Offset or Indirect in \'Applies To\' does not seem to work. Is there any other way to stop conditional formatting from breaking after inserting row/s

16条回答
  •  时光取名叫无心
    2021-01-01 12:30

    This is a general problem with conditional formats. If you insert rows or shift things around, Excel assumes that you want the conditional format to shift with the cells, and that you want to insert cells with their original formatting (or none at all).

    So it tries its best to split up the formatted range according to the changes. Unfortunately "its best" is not very good. In lucky cases, your formatting rules get duplicated without you noticing; in unlucky cases they break for some or all of the applied range.

    This is especially a problem if you work with ListObjects (a.k.a. "Excel tables"). Insert some rows, reorder it a bit, drag some values around and the next time you look into your conditional formatting list, you have dozens to hundreds of duplicate rules. (example: http://blog.contextures.com/archives/2012/06/21/excel-2010-conditional-formatting-nightmare/)

    In my experience the quickest way to fix the mess is to delete all rules and recreate them (or not).

    Some sidenotes:

    • The applies-to range is always absolute. There is no way around that.
    • To make matters worse, conditional formats are treated like volatile formulas, meaning they are recalculated on lots of occasions (opening another file, scrolling around, etc). If you do not notice the split-ups, they can slow down the whole application significantly after a while.
    • If you go for VBA, you probably want to use the Worksheet_Calculate event, at least if your formulas refer to other worksheets (be aware of names!)

提交回复
热议问题