1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| Dim Target As Range, MonRange As Range
Set MonRange = Range("A1:A101")
For Each Target In MonRange
Target.FormatConditions.AddDatabar
With Target.FormatConditions(1)
.MinPoint.Modify newtype:=xlConditionValueNumber, newvalue:=0
.MaxPoint.Modify newtype:=xlConditionValueNumber, newvalue:=100
Select Case Target.Value
Case 0
.BarColor.Color = RGB(255, 0, 0)
Target.Interior.Color = RGB(255, 0, 0) 'Rempli la cellule entière en rouge
Case 1 To 50
.BarColor.Color = RGB(255, Target.Value / 50 * 255, 0)
Case 51 To 80
.BarColor.Color = RGB(255 - (Target.Value / 160) * 255, Target.Value / 80 * 255, 0)
Case 81 To 100
.BarColor.Color = RGB(0, 255, 0)
End Select
End With
Next Target |
Partager