Private Sub test()
Dim myDic As Object
Dim z As Variant
Dim ar As Variant
lr = Cells(Rows.Count, "A").End(xlUp).Row
Set myDic = CreateObject("Scripting.Dictionary")
With myDic
For i = 2 To lr
.Item(Cells(i, "H").Value) = 1
If Not .exists(Cells(i, "H").Value) Then
.Add (Cells(i, "H").Value), Cells(i, "B")
End If
Next i
ar = myDic.Keys
AnzahlWerte = myDic.Count
End With
MsgBox TypeName(ar(1)) 'Ausgabe: String
MsgBox TypeName(Cells(2, "H").Value) 'Ausgabe: Strint
For i = 0 To AnzahlWerte - 1 'Werte in Dictionary
For z = 2 To lr 'Spalten
If (ar(i)) = (Cells(z, "H").Value) Then
Cells(z, "M").Value = ar(i)
Cells(z, "N").Value = Cells(z, "A").Value
' Else: MsgBox ar(i) & " ist nicht gleich" & " " & Cells(2, "H").Value
End If
Next z
Next i
End Sub