AW: Doppelte Werte in Array
20.08.2015 16:23:49
Jack_d
Hallo Jochen,
Ich würde es über ein Dictionary lösen. Das ist was den Abgleich angeht ganz komfortabel.
Hier mal ein Codezum probieren
(Werte in Spalte & Trägt die Doppelten mit Zeilenbezeichnung in Spalte C )
Grüße
Option Explicit
Sub DopIdent()
Dim A As Variant
Dim B As Variant
Dim Ai As Long
Dim Zeile As Long
Dim NEU As String
Dim ODict1 As Object
With Worksheets("Tabelle2")
Set ODict1 = CreateObject("scripting.dictionary")
A = .Range(.Cells(1, 1), .Cells(.Cells(Rows.Count, 1).End(xlUp).Row, 1))
For Ai = 1 To UBound(A)
If ODict1.exists(A(Ai, 1)) Then
NEU = NEU & A(Ai, 1) & " Zeile " & Ai & "-"
Else
ODict1(A(Ai, 1)) = Ai
End If
Next Ai
B = Split(NEU, "-")
For Zeile = 1 To UBound(B)
.Cells(Zeile, 3) = B(Zeile - 1)
Next Zeile
Set ODict1 = Nothing
A = ""
B = ""
End With
End Sub