ich möchte mir aus einzelnen Zellen einer Zeile einen Key zusammensetzen und dann in allen darunter leigenden Zeilen prüfen ob es dort einen identischen Key geben würde wenn ja, soll in den Key Zeilen eine Zahl in Spalte 7 eingetragen werden.
Grundsätzlich habe ich eine lösung, allerdings läuft die bei über 16.000 Zeilen schon eine gefühlte ewigkeit, da gibt es bestimmt eine bessere Lösung oder?
Danke
MFG
Thomas
Sub Aufloesen()
Application.ScreenUpdating = False
Dim lngRow As Long
Dim lngLastRow As Long
Dim strID As String
Dim i As Long
Dim strKeyFind
Dim lngrow2 As Long
i = 1
With tblDaten
lngLastRow = .Cells(Rows.Count, 1).End(xlUp).Row 'letzte nicht leere Zeile in Spalte 1 (A) ermitteln
If .Cells(lngRow, 7) = "" Then
strKeyFind = .Cells(lngRow, 8) & .Cells(lngRow, 9) & .Cells(lngRow, 5) & .Cells(lngRow, 10) & .Cells(lngRow, 12) 'Key wird erstellt der anschließend in allen Zeilen geprüft werden soll
For lngrow2 = lngRow + 1 To lngLastRow
If strKeyFind > .Cells(lngrow2, 8) & .Cells(lngrow2, 9) & .Cells(lngrow2, 5) & .Cells(lngrow2, 10) & .Cells(lngrow2, 12) Then
.Cells(lngRow, 7).NumberFormat = "@"
.Cells(lngrow2, 7).NumberFormat = "@"
.Cells(lngRow, 7) = i
.Cells(lngrow2, 7) = i
.Cells(lngRow, 7).NumberFormat = "@"
.Cells(lngrow2, 7).NumberFormat = "@"
.Cells(lngRow, 1).NumberFormat = "@"
.Cells(lngrow2, 1).NumberFormat = "@"
.Cells(lngRow, 1) = .Cells(lngRow, 2) & .Cells(lngRow, 3) & .Cells(lngRow, 5) & .Cells(lngRow, 10) & .Cells(lngRow, 12) & .Cells(lngRow, 4)
.Cells(lngrow2, 1) = .Cells(lngRow, 2) & .Cells(lngRow, 3) & .Cells(lngRow, 5) & .Cells(lngRow, 10) & .Cells(lngRow, 12) & .Cells(lngRow, 4)
.Cells(lngRow, 1).NumberFormat = "@"
.Cells(lngrow2, 1).NumberFormat = "@"
Else
.Cells(lngRow, 7).NumberFormat = "@"
.Cells(lngRow, 7) = i
.Cells(lngRow, 7).NumberFormat = "@"
.Cells(lngRow, 1).NumberFormat = "@"
.Cells(lngRow, 1) = .Cells(lngRow, 2) & .Cells(lngRow, 3) & .Cells(lngRow, 5) & .Cells(lngRow, 10) & .Cells(lngRow, 12) & .Cells(lngRow, 4)
.Cells(lngRow, 1).NumberFormat = "@"
End If
Next lngrow2
i = i + 1
End If
Next lngRow
End With
Application.ScreenUpdating = True
End Sub