ich bin zu dämlich, zumindest stell ich mich so an...... Ich möchte in einer Liste aus zwei Spalten - F = Datum, G = ein Eintrag dazu - immer die Hintergrundfarbe wechseln, bei einem neuen Datum, dabei immer zwischen 2 Farben wechseln, entweder gefärbt oder nicht gefärbt.
Zu den Datümern gilt:
- die Liste ist nach Spalte F mit den Datümern sortiert
- ein Datum kann 1 Mal vorkommen
- ein Datum kann öfter als 1 Mal vorkommen
- nicht jeder Tag kommt zwangsläufig vor
Beispiel, wie es aussehen kann:
28.08.2013
28.08.2013
30.08.2013
31.08.2013
03.09.2013
03.09.2013
03.09.2013
07.09.2013
08.09.2013
Ich tu da schon ewig rum, spiel mich mit zwei Do..Loop-Schleifen, es dauert ewig, und noch dazu stimmt's nicht:
Sub Vergleich()
Dim iRowA As Integer, iRowB As Integer
Dim iColor As Integer
Dim iRowC As Integer
Dim bln As Boolean, blnColor As Boolean
Application.ScreenUpdating = False
Worksheets("Daten").Activate
iRowA = 3
iColor = 1
Columns("F:G").Interior.ColorIndex = xlNone
With Range(Cells(1, 6), Cells(1, 7)).Interior
.ColorIndex = 5
.Pattern = xlSolid
End With
Do Until IsEmpty(Cells(iRowA, 6))
iRowB = iRowA + 1
Do Until IsEmpty(Cells(iRowB, 6))
If Cells(iRowA, 6) Cells(iRowB, 6) Then
If Cells(iRowA, 6).Interior.ColorIndex = xlColorIndexNone Then
Cells(iRowA, 6).Interior.ColorIndex = 36
Cells(iRowA, 7).Interior.ColorIndex = 36
Else
Cells(iRowA, 6).Interior.ColorIndex = xlColorIndexNone
Cells(iRowA, 7).Interior.ColorIndex = xlColorIndexNone
End If
End If
iRowB = iRowB + 1
bln = False
Loop
blnColor = False
iRowA = iRowA + 1
Loop
End Sub
Darum bitte ich um Eure Hilfe. Das geht doch sicher einfacher, aber ich steh am Schlauch.........
Vielen Dank schonmal und Grüße
Franz