I have a spreadsheet that is in Google Sheets which has a column that I want to format conditionally. I want to format it, such that groups of rows which all hold the same value are dark grey, while they next group of rows of all the same value are light grey. For example, I want the sheet to look something like this:

The numbers will not neccesarily be grouped in order, so I can't just use `=mod(a1,2)=1`

for the conditional format. I also would like it to update so that no matter how the other columns are filtered, this column remains such that every time the value in the next row is different, it and its duplicates are all a new color, mainly for visualization, to see which data is grouped together.

If I'm to use the formulae `=isodd(countunique(a$2:a2))`

and `=isodd(countunique(a$2:a2))`

and then apply some filter, then I get the following, which doesn't alternate the colors based on what is shown.

Any help would be great. Thanks.

Try

```
=isodd(countunique(a$1:a1))
```

for the light grey and

```
=iseven(countunique(a$1:a1))
```

for the dark grey

**EDIT**

The same question was asked in Excel recently and I realised it would be more straightforward just to count the changes of value like this:

```
=ISEVEN(SUMPRODUCT(--(A$1:A1<>A$2:A2)))
```

It doesn't solve the filtering question though.

- Run a Google apps script automatically upon loading a Google Site?
- How to implement the makeApiCall() method after migrating Google Sheets API v3 to v4 with Oauth Authorization in Javascript
- How to return date values from an arrayformula in an index:match formula (left/right function)
- find & replace commas with newline on Google Spreadsheet
- How can I count text strings based on adjacent cell?
- Conditional format alternate between 2 colours for groups of rows based on value change
- How to limit a max value in a cell?
- Is there a way to combine formula?
- Google Sheets - Number of days since the last date a range of cells
- How can you sum up the amount of items in a month?