Boris Helm
2009-07-28 17:33:26 UTC
Hallo,
ich möchte eine bedingte Formatierung mit VBA steuern. Habe im Internet den
untenstehenden Code gefunden und die Teile ab ...,xlequal,.. angepasst.
Jetzt erkennt Excel das nur als Text. Wie bringe ich ihm nun bei Werte >0,01
und <0,9 entsprechend zu formatieren.
Über einen kompletten Code wäre ich natürlich auch dankbar :-)
Vielen Dank und Gruß
Boris
P.S. Hier der Code
Public Sub BedingtesAmpelFormat()
Dim Wert As Variant
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
'*** Bedingte Formatierung anlegen
.FormatConditions.Delete
' Bedingung für roten Zellhintergrund
With .FormatConditions.Add(xlCellValue, xlEqual, ">0,01 and <0,9")
.Font.ColorIndex = 3
.Interior.ColorIndex = 3
End With
' Bedingung für grünen Zellhintergrund
With .FormatConditions.Add(xlCellValue, xlEqual, ">=0,9 and <0,94")
.Font.ColorIndex = 50
.Interior.ColorIndex = 50
End With
' Bedingung für gelben Zellhintergrund
With .FormatConditions.Add(xlCellValue, xlEqual, ">= 0,94 and <=1")
.Font.ColorIndex = 6
.Interior.ColorIndex = 6
End With
End With
End Sub
ich möchte eine bedingte Formatierung mit VBA steuern. Habe im Internet den
untenstehenden Code gefunden und die Teile ab ...,xlequal,.. angepasst.
Jetzt erkennt Excel das nur als Text. Wie bringe ich ihm nun bei Werte >0,01
und <0,9 entsprechend zu formatieren.
Über einen kompletten Code wäre ich natürlich auch dankbar :-)
Vielen Dank und Gruß
Boris
P.S. Hier der Code
Public Sub BedingtesAmpelFormat()
Dim Wert As Variant
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
'*** Bedingte Formatierung anlegen
.FormatConditions.Delete
' Bedingung für roten Zellhintergrund
With .FormatConditions.Add(xlCellValue, xlEqual, ">0,01 and <0,9")
.Font.ColorIndex = 3
.Interior.ColorIndex = 3
End With
' Bedingung für grünen Zellhintergrund
With .FormatConditions.Add(xlCellValue, xlEqual, ">=0,9 and <0,94")
.Font.ColorIndex = 50
.Interior.ColorIndex = 50
End With
' Bedingung für gelben Zellhintergrund
With .FormatConditions.Add(xlCellValue, xlEqual, ">= 0,94 and <=1")
.Font.ColorIndex = 6
.Interior.ColorIndex = 6
End With
End With
End Sub