Ich möchte in einigen Spalten die Farben zählen (Azahl rote + Anzahl grüne Felder)pro Spalte
Die Farben stammen aus einer bedingten Formatierung (Formel)nicht Zellwert.
Habe mal einen Beitrag gefunden
Bei dieser Lösung wird aber nur die Bedingung der ersten bedingten
Formatierung erfüllt. (d.h Ist die erste bedingte Formatierung = rot werden nur die roten gezählt Bedingung 2 (grün) wird nicht beachtet.
Kann mir jemand weiterhelfen ?
Hier der Code
Dim Formel As Integer
Dim Formel2 As Integer
Function BedZählen(Bereich As Range)
s = 0
gefunden = False
For Each c In Bereich.Cells
If c.FormatConditions.Count > 0 Then
gefunden = True
If c.FormatConditions(1).Type = xlCellValue Then
Formel = c.FormatConditions(1).Formula1
OP = c.FormatConditions(1).Operator
Select Case OP
Case 0
Case xlBetween
Formel2 = c.FormatConditions(1).Formula2
Bed = Formel <= c.Value And c.Value <= Formel2
Case xlEqual
Bed = c.Value = Formel
Case xlGreater
Bed = c.Value > Formel
Case xlGreaterEqual
Bed = c.Value >= Formel
Case xlLess
Bed = c.Value < Formel
Case xlLessEqual
Bed = c.Value <= Formel
Case xlNotBetween
Formel2 = c.FormatConditions(1).Formula2
Bed = Formel > c.Value Or c.Value > Formel2
Case xlNotEqual
Bed = c.Value <> Formel
End Select
If Bed Then
s = s + 1
End If
End If
Else
If gefunden = False Then
BedZählen = ""
End If
End If
Next
If gefunden = True Then
BedZählen = s
End If
End Function