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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| Sub colorie()
Dim rouge, vert As Integer
For li = 6 To 51
Set myrange = Worksheets("Feuil1").Range(Cells(li, 3), Cells(li, 21))
maxli = Application.WorksheetFunction.Max(myrange)
minli = maxli
For co = 3 To 16
If Cells(li, co).Text <> "" Then
If Cells(li, co).Value < minli Then minli = Cells(li, co).Value
End If
Next co
iEcart = maxli - minli
If iEcart <> 0 Then ncoef = 1 / iEcart
For co = 3 To 16
If Cells(li, co).Text = "" Or iEcart = 0 Then
Cells(li, co).Interior.Color = RGB(172, 172, 172)
Else
valeur = Cells(li, co).Value
rouge = (valeur - minli) * ncoef * 255
vert = 255 - rouge
Cells(li, co).Interior.Color = RGB(rouge, vert, 0)
End If
Next co
Next li
End Sub |
Partager