Google Sheets – Alternate Row Color by Unique Sorted Names

conditional formattinggoogle sheets

Background

I have a sheet that is sorted by Country Names, all unique Country Names are associated with more than one City.

Question

How do I alternate the color of every other Country Name, such that I can more easily distinguish which Cities belong to which Countries?

Data sample:

     A       B
1 Finland   Helsinki
2 Finland   Turku
3 France    Lyon
4 France    Metz
5 France    Paris
6 Germany   Aachen
7 Germany   Berlin
8 Germany   Bielefeld
9 Italy     Milan
10 Italy    Pavia
11 Italy    Pesaro
12 Italy    Rimini
13 Italy    Rome
14 Norway   Bergen
15 Norway   Oslo
16 Norway   Stavanger
17 Norway   Trondheim

Best Answer

Please select ColumnsA:B and apply apply a Custom formula is of:

=and(A1<>"",isodd(counta(unique($A$1:$A1)))=TRUE)

with one formatting of choice, and:

=and(A1<>"",isodd(counta(unique($A$1:$A1)))=FALSE)

with a different formatting of your choice.

AND
ISODD
COUNTA
UNIQUE