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 45
| Function TestCondition(Target As Range) As Boolean
Dim MonFormat As FormatCondition, Lim1 As Variant, Lim2 As Variant, Result As Boolean
Dim Valeur As Variant
For Each MonFormat In Target.FormatConditions
If MonFormat.Type = xlCellValue Then
Valeur = Target.Value
Select Case MonFormat.Operator
Case xlBetween, xlNotBetween
Lim1 = Application.Evaluate(MonFormat.Formula1)
Lim2 = Application.Evaluate(MonFormat.Formula2)
Result = IIf(Application.WorksheetFunction.Min(Lim1, Lim2) < Valeur And Application.WorksheetFunction.Max(Lim1, Lim2) > Valeur, True, False)
TestCondition = Result Eqv MonFormat.Operator = xlBetween
Case xlEqual, xlNotEqual
Lim1 = Application.Evaluate(MonFormat.Formula1)
Result = Lim1 = Valeur
TestCondition = Result Eqv MonFormat.Operator = xlEqual
Case xlLess, xlGreater
Lim1 = Application.Evaluate(MonFormat.Formula1)
If Lim1 <> Valeur Then
Result = IIf(Lim1 > Valeur, True, False)
TestCondition = Result Eqv MonFormat.Operator = xlLess
Else
TestCondition = False
End If
Case xlLessEqual, xlGreaterEqual
Lim1 = Application.Evaluate(MonFormat.Formula1)
If Lim1 <> Valeur Then
Result = IIf(Lim1 > Valeur, True, False)
TestCondition = Result Eqv MonFormat.Operator = xlLess
Else
TestCondition = True
End If
End Select
Else
TestCondition = Application.Evaluate(MonFormat.Formula1)
End If
If TestCondition = True Then Exit Function
Next
End Function |
Partager