if your numbers are divided into pieces of repeating repetitions of different numbers, you can use this VBA code:
Sub main() Dim item As Variant Dim startRow As Long Dim okHighlight As Boolean With Range("A1", Cells(Rows.count, 1).End(xlUp)) For Each item In GetUniqueValues(.Cells).Items If okHighlight Then .Range(.Cells(startRow, 1), .Cells(item, 1)).Interior.ColorIndex = 48 startRow = item + 1 okHighlight = Not okHighlight Next End With End Sub Function GetUniqueValues(rng As Range) As Dictionary Dim cell As Range Dim dict As Dictionary Set dict = New Dictionary With dict For Each cell In rng .item(cell.Value) = cell.row - rng.Rows(1).row + 1 Next End With Set GetUniqueValues = dict End Function
possible conditional formatting approach with auxiliary column
on condition:
then
write the following formula in the cells of auxiliary column B:
= IF (A2 <> A1, B1 + 1.0)
apply conditional formatting to column A with the following formula:
= INT (B2 / 2) = B2 / 2
and selecting the format you want to highlight with cells
source share