Excel - Conditional Formatting - insert row

前端 未结 16 1579
轮回少年
轮回少年 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:17

    I'm building a solution that others with mixed Excel skill levels will come into play, so I needed something easier and more consistent than to have them remember to copy and paste a certain way.

    In Excel 2016, you can insert a table from a selected range which then gives you the benefit of using structured references (example: tblTOP[Type], to reference data in the Type column of the table named tblTOP).

    I then found this answer at Microsoft's site that shows an effective way to reference a table in the formula part of CF: conditional formatting structured references


    So, with that established...

    This is what I'm working with:

    tblTop Columns

    I set up my conditional formatting so that when I change the Type value anywhere between A to E, it will change that row to a corresponding color. (Example shown: B turns the row to green)

    This was accomplished by using the formula =INDIRECT("tblTOP[Type]")="B"

    When I went to add a row though, I got the same formatting applied to that second row :(.

    Broke CF between two rows

    CF formula that worked

    Long story short, the following formula is what I came up with to apply my CF rule to that particular row and not affect any rows being added or taken away:

    =INDIRECT("tblTOP[@Type]")="B"

    The addition of the '@' in front of the structured reference keeps things happening just for that given row. Nice.

    So now I can tab through or use the context menu to add a new row and it awaits the type selection to determine the color for that row only.

    New Row added clean

    New Row working as expected

    I haven't tested it with pasting cells as the purpose of this table is for the end user to enter data and add/delete rows as needed, so I can't say if this will work with pasting a row.

    Hope this helps someone with conditional formatting in a table.

提交回复
热议问题