Hi, every day i have to update an excel file. This includes formatting column B. (see picture above). I haven't found VBA code yet, to geht this kind of formatting via VBA. in the picture you see a subset of formatting rules, there are more. But there is only those three colors, which I have the hex code.
yellow #9C5700
red #9C0006
green #006100
' (1) Highlight defined good as green values
With Range("b:b").FormatConditions.Add(xlCellValue, xlEqual, "=2")
.Interior.ColorIndex = 6
.StopIfTrue = False
End With
With Range("b:b").FormatConditions.Add(xlCellValue, xlEqual, "in Anfrage")
.Interior.ColorIndex = 6
.StopIfTrue = False
End With
' (2) Highlight defined ok as yellow values
With Range("b:b").FormatConditions.Add(xlCellValue, xlEqual, "=1")
.Interior.ColorIndex = 4
.StopIfTrue = False
End With
With Range("b:b").FormatConditions.Add(xlCellValue, xlEqual, "ok")
.Interior.ColorIndex = 4
.StopIfTrue = False
End With
' (2) Highlight defined bad as red values
With Range("b:b").FormatConditions.Add(xlCellValue, xlEqual, "=3")
.Interior.ColorIndex = 3
.StopIfTrue = False
End With
With Range("b:b").FormatConditions.Add(xlCellValue, xlEqual, "kritisch")
.Interior.ColorIndex = 3
.StopIfTrue = False
End With
End Sub
I used this code, but i would like to use the hex colors. How do I use those?
