wie kann man in einer Tabelle doppelt vorkommende Zellinhalte so bunt markieren, daß je doppeltem, oder mehrfach gleichem Inhalt je eine andere Farbe als Hintergrund erscheint?
Danke
A | |
1 | Liste |
2 | x |
3 | a |
4 | b |
5 | c |
6 | a |
7 | d |
8 | a |
9 | b |
10 | d |
11 | f |
12 | a |
Bedingte Formatierungen der Tabelle | |||||||||||||||||||||
|
Option Explicit
Sub Mehrfache_faerben()
Dim lngZ As Long, intS As Integer, intF As Integer, lngV As Long, varW, zz As Long
Const intSp As Integer = 1 ' 1 für Spalte A, anpassen
lngZ = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(1, intSp), Cells(lngZ, intSp)).Interior.ColorIndex = xlColorIndexNone
Columns(1).Insert
With Range(Cells(1, intSp), Cells(lngZ, intSp))
.Formula = "=ROW()"
.Value = .Value
End With
intS = intSp + 1
Range(Rows(1), Rows(lngZ)).Sort Key1:=Cells(1, intS), Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom
intF = 2
lngV = 1
varW = Cells(1, intS)
For zz = 2 To lngZ + 1
If varW <> Cells(zz, intS) Then
If zz > lngV + 1 Then
If intF < 55 Then intF = intF + 1 Else Exit For ' so
'intF = IIf(intF < 55, intF + 1, 3) ' oder so
Range(Cells(lngV, intS), Cells(zz - 1, intS)).Interior.ColorIndex = intF
End If
lngV = zz
varW = Cells(zz, intS)
End If
Next zz
Range(Rows(1), Rows(lngZ)).Sort Key1:=Cells(1, intSp), Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Columns(intSp).Delete
End Sub
Rückmeldung wäre nett! - Grüße von Erich aus Kamp-LintfortDie erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen