Option Explicit
Private Sub vergleichen()
Dim a&, b&, E1&, E2&
Dim rng1 As Range, rng2 As Range, Dat1, Dat2
Dim V1, V2
With Sheets(1)
Set rng1 = .Range(.Cells(Rows.Count, 1).End(xlUp), .Cells(1, 2)) 'original
Dat1 = rng1.Value
End With
E1 = UBound(Dat1)
With Sheets(2)
Set rng2 = .Range(.Cells(Rows.Count, 1).End(xlUp), .Cells(1, 2)) 'neue Tabelle
Dat2 = rng2.Value
End With
E2 = UBound(Dat2)
For a = 1 To E1
V1 = Dat1(a, 1)
For b = 1 To E2
V2 = Dat2(b, 1)
If V1 = V2 Then
Dat1(a, 2) = Dat2(b, 2) 'spalte neben übereinstimmung
Exit For
End If
Next
Next
rng1.Value = Dat1
Das ist eigentlich alles was du brauchst, Spalten und Bereiche musst du selbst festlegen...
|