AW: VBA Vergleich
12.10.2010 15:02:12
Tino
Hallo,
so schnell war ich mit meiner Version nicht fertig.
Sub Liste_Neu()
Dim ArrayAlt, ArrayNeu, ArrayTmp(), oDic As Object
Dim nCount As Long, lngCol As Long, lngRow As Long
Set oDic = CreateObject("Scripting.Dictionary")
With Tabelle1 'Alt
ArrayAlt = .Range("N13", .Cells(.Rows.Count, 14).End(xlUp)).Value2
For nCount = 1 To Ubound(ArrayAlt)
oDic(ArrayAlt(nCount, 1)) = 0
Next nCount
Erase ArrayAlt
End With
With Tabelle2 'Neu
ArrayNeu = .Range("A13", .Cells(.Rows.Count, 14).End(xlUp)).Value2
Redim Preserve ArrayTmp(1 To Ubound(ArrayNeu, 2), 1 To Ubound(ArrayNeu))
For nCount = 1 To Ubound(ArrayNeu)
If Not oDic.exists(ArrayNeu(nCount, 14)) Then
lngRow = lngRow + 1
For lngCol = 1 To 14
ArrayTmp(lngCol, lngRow) = ArrayNeu(nCount, lngCol)
Next lngCol
End If
Next nCount
End With
With Tabelle3 'Fehlende in Neu
.Range("A13", .Cells(.Rows.Count, 14)).ClearContents
If lngRow > 0 Then
Redim Preserve ArrayTmp(1 To Ubound(ArrayTmp), 1 To lngRow)
ArrayTmp = Application.Transpose(ArrayTmp)
With .Range("A13").Resize(lngRow, Ubound(ArrayTmp, 2))
.Cells = ArrayTmp
.EntireColumn.AutoFit
End With
End If
End With
End Sub
Gruß Tino