Farblich ausfüllen
09.05.2007 16:06:10
Oliver
ich möchte mit dem folgenden erreichen, dass unter bestimmten Bedingungen Kästchen eingefärbt werden. Die bedingt Formatierung lässt das in dem Umfang meiner Meinung nach nicht zu.
Sub Farbe()
Dim i As Integer
For i = 4 To 100
If Cells(i, 3) = Cells(2, 4) Then Cells(i, 4).Select
With Selection.Interior
.ColorIndex = 45
.Pattern = xlSolid
End With
If Cells(i, 3) = Cells(2, 5) Then Range(Cells(i, 4), Cells(i, 5)).Select
With Selection.Interior
.ColorIndex = 43
.Pattern = xlSolid
End With
If Cells(i, 3) = Cells(2, 6) Then Range(Cells(i, 4), Cells(i, 6)).Select
With Selection.Interior
.ColorIndex = 50
.Pattern = xlSolid
End With
If Cells(i, 3) = Cells(2, 7) Then Range(Cells(i, 4), Cells(i, 7)).Select
With Selection.Interior
.ColorIndex = 42
.Pattern = xlSolid
End With
If Cells(i, 3) = Cells(2, 8) Then Range(Cells(i, 4), Cells(i, 8)).Select
With Selection.Interior
.ColorIndex = 41
.Pattern = xlSolid
End With
If Cells(i, 3) = Cells(2, 9) Then Range(Cells(i, 4), Cells(i, 9)).Select
With Selection.Interior
.ColorIndex = 13
.Pattern = xlSolid
End With
If Cells(i, 3) = Cells(2, 10) Then Range(Cells(i, 4), Cells(i, 10)).Select
With Selection.Interior
.ColorIndex = 48
.Pattern = xlSolid
End With
If Cells(i, 3) = Cells(2, 11) Then Cells(i, 11).Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
If Cells(i, 3) = Cells(2, 12) Then Cells(i, 12).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Next i
End Sub
Nun werden die Zellen zwar eingefärbt, jedoch nicht mit unterschiedlichen Farben. Woran liegt das? Vielen Dank schon im Voraus.
VG
Oliver