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 44
|
Public Function CouleurMFC(RG As Range, Optional Mode As Byte = 0) As Variant
Dim e As Long, i As Byte, LoTest As Boolean
Dim LoMFC As FormatCondition
Application.Volatile
'boucle sur le nombre de condition(s)
'Si pas de MFC .FormatConditions.Count renvoi 0
For i = 1 To RG.FormatConditions.Count
Set LoMFC = RG.FormatConditions(i)
If LoMFC.Type = xlCellValue Then
'tester le type de la formule entrée
Select Case LoMFC.Operator
Case xlEqual
LoTest = RG = Evaluate(LoMFC.Formula1)
Case xlNotEqual
LoTest = RG <> Evaluate(LoMFC.Formula1)
Case xlGreater
LoTest = RG > Evaluate(LoMFC.Formula1)
Case xlGreaterEqual
LoTest = RG >= Evaluate(LoMFC.Formula1)
Case xlLess
LoTest = RG < Evaluate(LoMFC.Formula1)
Case xlLessEqual
LoTest = RG <= Evaluate(LoMFC.Formula1)
Case xlNotBetween
LoTest = (RG < Evaluate(LoMFC.Formula1) Or RG > Evaluate(LoMFC.Formula2))
Case xlBetween
LoTest = (RG >= Evaluate(LoMFC.Formula1)) And (RG <= Evaluate(LoMFC.Formula2))
End Select
If LoTest Then
'Peu ajouter d'autre format si nécessaire,
'comme la bordure, la police etc..
Select Case Mode
Case 0
CouleurMFC = LoMFC.Interior.ColorIndex
Case 1
CouleurMFC = LoMFC.Interior.Color
End Select
Exit Function
End If
End If
Next i
CouleurMFC = 0
End Function |
Partager