Using conditional formatting to alternate the formatting of data by category

后端 未结 3 1078
无人共我
无人共我 2021-01-14 09:24

I have a spreadsheet with a bunch of rows like this:

Name    |   ID    |   Category  |    Attributes...
-----------------------------------------------------         


        
3条回答
  •  广开言路
    2021-01-14 09:42

    I don't believe this is easily done with the built in tools, however you can add a calculated column, then apply conditional formatting based on it.

    This example assumes that your data is sorted by the category column. If you are not sorting the table by the category column, you will need one more step, which is to create a lookup table where you calculate the TRUE/FALSE COL_STRIPE value, then in your COL_STRIPE column, perform a VLOOKUP of it.

    Here is a working example

    1. Add the Calculated Column
      • Add a new column called COL_STRIPE, in my example this is column E.
      • Add the following formula to the column: =IF(C2<>C1,IFERROR(NOT(E1),FALSE),E1).
      • This column has the value true or false.
      • If the category is the same as the previous row, the COL_STRIPE value remains the same, otherwise it is negated.
      • In the case of the first row, the IFERROR() statement will set it to false.
      • Copy this formula down the column.
    2. Apply The Conditional Format
      • Highlight your table
      • Go to the Home Ribbon > Conditional Formatting > Highlight Cells Rules > More Rules
      • Use a formula to determine which cells to format: =NOT($E2), this will apply the format to all rows for which the E column (COL_STRIPE) is FALSE
      • Click the format button to set your desired background color.

提交回复
热议问题