Sub cf()
Dim lr As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
Range("A2:C" & lr).ClearFormats
For x = 3 To lr
If Cells(x, 1) <> Cells(x - 1, 1) And Cells(x - 1, 1).Interior.Color <> vbYellow Then
Range(Cells(x, 1), Cells(x, 3)).Interior.Color = vbYellow
End If
If Cells(x, 1) = Cells(x - 1, 1) And Cells(x - 1, 1).Interior.Color = vbYellow Then Range(Cells(x, 1), Cells(x, 3)).Interior.Color = Cells(x - 1, 1).Interior.Color
Next x
End Sub
It looks like this assumes that the Customer numbers are in column A starting in row 2 and this column is sorted.This code will highlight every other customer number yellow.
=ISODD(SUMPRODUCT(1/COUNTIF($A$2:$A2,$A$2:$A2)))
It looks like this assumes that the Customer numbers are in column A starting in row 2 and this column is sorted.
Under those same assumptions, you can do the same thing with Conditional Formatting, not requiring any VBA.
Just highlight rows 2 down to the end, and enter this Conditional Formatting formula:
and choose your formatting color.Code:=ISODD(SUMPRODUCT(1/COUNTIF($A$2:$A2,$A$2:$A2)))