Dein Code
Sub Formatierung()
Dim i As Long
Dim c As Integer
Dim a As String
i = 2 'Start in Zeile 2
c = 35 ' 1. Farbe
Do While (Cells(i, 1) <> "")
If (Cells(i, 1) <> Cells(i - 1, 1)) Then 'Überprüfe ob Differenz zur Vorzelle in Spalte A
If c = 35 Then
c = 36 '2. Farbe
Else
c = 35 '1. Farbe
End If
End If
Rows(Trim(Str(i)) + ":" + Trim(Str(i))).Interior.ColorIndex = c
i = i + 1
Loop
End Sub
Stopt wegen der "" - Bedingung an der ersten, leeren Zelle
Sub Sowas()
Dim rngData As Range, rngA As Range, rngC As Range
Dim lngIntC As Long
lngIntC = 35
Set rngData = Range(Cells(2, 1), Cells(Cells(Rows.Count, 1).End(xlUp).Offset(1).Row, 1))
Set rngData = rngData.ColumnDifferences(rngData.Cells(rngData.Cells.Count))
For Each rngA In rngData.Areas
For Each rngC In rngA.Cells
If rngC <> rngC.Offset(-1) Then
lngIntC = IIf(lngIntC = 35, 36, 35)
rngC.EntireRow.Interior.ColorIndex = lngIntC
Else
rngC.EntireRow.Interior.ColorIndex = lngIntC
End If
Next rngC
Next rngA
End Sub
|