26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| Private Function ConditionNo(ByVal rgeCell As Range) As Integer
Dim iconditionscount As Integer Dim objFormatCondition As FormatCondition
For iconditionscount = 1 To rgeCell.FormatConditions.Count Set objFormatCondition = rgeCell.FormatConditions(iconditionscount) Select Case objFormatCondition.Type Case xlCellValue Select Case objFormatCondition.Operator Case xlBetween: If Compare(rgeCell.Value, ">=", objFormatCondition.Formula1) = True And _ Compare(rgeCell.Value, "<=", objFormatCondition.Formula2) = True Then _ ConditionNo = iconditionscount Case xlNotBetween: If Compare(rgeCell.Value, "<=", objFormatCondition.Formula1) = True And _ Compare(rgeCell.Value, ">=", objFormatCondition.Formula2) = True Then _ ConditionNo = iconditionscount Case xlGreater: If Compare(rgeCell.Value, ">", objFormatCondition.Formula1) = True Then _ ConditionNo = iconditionscount Case xlEqual: If Compare(rgeCell.Value, "=", objFormatCondition.Formula1) = True Then _ ConditionNo = iconditionscount Case xlGreaterEqual: If Compare(rgeCell.Value, ">=", objFormatCondition.Formula1) = True Then _ ConditionNo = iconditionscount Case xlLess: If Compare(rgeCell.Value, "<", objFormatCondition.Formula1) = True Then _ ConditionNo = iconditionscount Case xlLessEqual: If Compare(rgeCell.Value, "<=", objFormatCondition.Formula1) = True Then _ ConditionNo = iconditionscount Case xlNotEqual: If Compare(rgeCell.Value, "<>", objFormatCondition.Formula1) = True Then _ ConditionNo = iconditionscount If ConditionNo > 0 Then Exit Function End Select
Case xlExpression If Application.Evaluate(objFormatCondition.Formula1) Then ConditionNo = iconditionscount Exit Function End If End Select
Next iconditionscount End Function
|