Re : Calcul de cellules colorees mfc
Bonjour,
Ci-dessous la formule :
Function SommeCoulMFC(champ As Range, coul)
Application.Volatile
t = 0
For Each c In champ
If CouleurMFC(c) = coul Then
t = t + c.Value
End If
Next c
SommeCoulMFC = t
End Function
Function CouleurMFC(cel)
Application.Volatile
Set c = Range(cel.Address)
ff = Array("Somme", "aujourdhui()", "nb.si", "equiv", "recherchev", _
"Nbval", "sommeprod", "joursem", "gauche", "droite", "stxt")
fa = Array("Sum", "today()", "countif", "match", "vlookup", _
"counta", "sumproduct", "weekday", "left", "right", "mid")
a = Array("=", ">", "<", ">=", "<=", "<>", "BETWEEN")
b = Array(xlEqual, xlGreater, xlLess, xlGreaterEqual, xlLessEqual, xlNotEqual, xlBetween)
i = 1
Do While i <= c.FormatConditions.Count And Not témoin
If c.FormatConditions(i).Type = xlCellValue Then
tmp1 = Evaluate(c.FormatConditions(i).Formula1)
oper = a(Application.Match(c.FormatConditions(i).Operator, b, 0) - 1)
If oper <> "BETWEEN" Then
If Evaluate(c & oper & tmp1) Then
coul = c.FormatConditions(i).Interior.ColorIndex
témoin = True
End If
Else
tmp2 = Evaluate(c.FormatConditions(i).Formula2)
If Evaluate("AND(" & c & ">=" & tmp1 & "," & c & "<=" & tmp2 & ")") Then
coul = c.FormatConditions(i).Interior.ColorIndex
témoin = True
End If
End If
Else
z = c.FormatConditions(i).Formula1
For k = LBound(ff) To UBound(ff)
z = Replace(z, UCase(ff(k)), UCase(fa(k)))
Next k
If Evaluate(z) = True Then
coul = c.FormatConditions(i).Interior.ColorIndex
témoin = True
End If
End If
i = i + 1
Loop
CouleurMFC = coul
End Function
Par ailleurs, sur un poste également équipé d'excel 2003 cette formule ne fonctionne pas.
Est ce une erreur de ma part dans l'utilisation de cette formule? Le fait que l'on soit en réseau?
Merci de votre réponse.
A bientot
Mag