mithilfe eines Makros lasse ich per Button meine Zellen bedingt formatieren.
Hier ein Beispiel:
Range("B2").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=UND(HEUTE()> B2 + 5; ODER(C2 = ""EL1""; C2= ""EL0""; C2=""EL2""))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=UND(HEUTE()> B2 + 2; C2 = ""EL1""; HEUTE()< B2 + 5)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 7701247
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Das Ganze geht noch weiter für B4, B5, usw.
Ich möchte das Ganze variabel gestalten und habe es mit einer for-Schleife probiert.
Problem ist, dass die Bedingung sich ja auch ändert und dort klappt das nicht, wenn ich die Variable der for-Schleife einfüge.
Hat jemand eine Idee?
Freundliche Grüße