1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Function quelle_couleur(R1 As Range, R2 As Range, C1 As Long, C0 As Long, d As Long)
Dim formula As String
formula = "IF(" & R1.Address(0, 0) & "-" & R2.Address(0, 0) & ">" & d & "," & Chr(34) & C1 & Chr(34) & "," & Chr(34) & C0 & """)"
c = Val(Evaluate(formula))
'Debug.Print formula & "couleur resultante = " & c
quelle_couleur = c
End Function
'
'
Sub MFCVBA()
For i = 1 To 100
Cells(i, 2).Interior.Color = quelle_couleur(Cells(i, 2), Cells(i, 1), RGB(255, 150, 255), vbGreen, 31) '+ d'un mois'rose claire
Cells(i, 2).Interior.Color = quelle_couleur(Cells(i, 2), Cells(i, 1), RGB(255, 0, 255), Cells(i, 2).Interior.Color, 92) '+ de 3 mois'magenta
Cells(i, 2).Interior.Color = quelle_couleur(Cells(i, 2), Cells(i, 1), vbRed, Cells(i, 2).Interior.Color, 365) '+d'un an' rouge
Cells(i, 2).Interior.Color = quelle_couleur(Cells(i, 2), Cells(i, 1), RGB(255, 255, 100), Cells(i, 2).Interior.Color, 500) '+ de 500 jours jaune paille
Next
End Sub |