ich möchte in einer Spalte die Zellen nach Farben zählen lassen. Es soll dabei aber berücksichtigt werden, dass Zellen mit dem gleichen Inhalt nur einmal gezählt werden. das ganze hätte ich gerne automatisch, also ohne manuelle Operationen wie Spezialfilter etc.
Ein Macro das Zellen nach Farben zählt habe ich bereits. Es sieht so aus:
Sub Farbenzählen()
Dim Zelle As Object
Dim rot%, lila%, gelb%, orange%, grün%, blau%, grau%
rot = 0: lila = 0: gelb = 0: orange = 0: grün = 0: blau = 0: grau = 0
[M15:M2000].Select
For Each Zelle In Selection
If Zelle.Interior.ColorIndex = 22 Then rot = rot + 1
If Zelle.Interior.ColorIndex = 39 Then lila = lila + 1
If Zelle.Interior.ColorIndex = 6 Then gelb = gelb + 1
If Zelle.Interior.ColorIndex = 45 Then orange = orange + 1
If Zelle.Interior.ColorIndex = 4 Then grün = grün + 1
If Zelle.Interior.ColorIndex = 8 Then blau = blau + 1
If Zelle.Interior.ColorIndex = 15 Then grau = grau + 1
Next
[K6].Select
ActiveCell.Formula = rot
ActiveCell.Offset(1, 0).Select
ActiveCell.Formula = lila
ActiveCell.Offset(1, 0).Select
ActiveCell.Formula = gelb
ActiveCell.Offset(1, 0).Select
ActiveCell.Formula = orange
ActiveCell.Offset(1, 0).Select
ActiveCell.Formula = grün
ActiveCell.Offset(1, 0).Select
ActiveCell.Formula = blau
ActiveCell.Offset(1, 0).Select
ActiveCell.Formula = grau
ActiveCell.Offset(1, 0).Select
End Sub