Sub
CheckDoppelte()
Dim
xRg
As
Range
Dim
xTxt
As
String
Dim
xCell
As
Range
Dim
xChar
As
String
Dim
xCellPre
As
Range
Dim
xCIndex
As
Long
Dim
xCol
As
Collection
Dim
I
As
Long
On
Error
Resume
Next
If
ActiveWindow.RangeSelection.Count > 1
Then
xTxt = ActiveWindow.RangeSelection.AddressLocal
Else
xTxt = ActiveSheet.UsedRange.AddressLocal
End
If
Set
xRg = Range(
"F10:G100"
)
If
xRg
Is
Nothing
Then
Exit
Sub
xCIndex = 2
Set
xCol =
New
Collection
For
Each
xCell
In
xRg
On
Error
Resume
Next
If
xCell.Value <>
""
Then
xCol.Add xCell, xCell.Text
If
Err.Number = 457
Then
xCIndex = xCIndex + 1
Set
xCellPre = xCol(xCell.Text)
If
xCellPre.Interior.ColorIndex = xlNone
Then
xCellPre.Interior.Color = RGB(xRed, xGreen, xBlue)
xCell.Interior.Color = xCellPre.Interior.Color
ElseIf
Err.Number = 9
Then
MsgBox
"Zu viele Duplikate - Frabe ist ausgegangen!"
, vbCritical,
"Dupplikate markieren"
Exit
Sub
End
If
xRed = Application.WorksheetFunction.RandBetween(0, 255)
xGreen = Application.WorksheetFunction.RandBetween(0, 255)
xBlue = Application.WorksheetFunction.RandBetween(0, 255)
On
Error
GoTo
0
End
If
Next
End
Sub