AW: Sortieren nach Spalte B
20.07.2021 20:24:43
Nepumuk
Hallo,
ich habe das soweit fertig, allerdings bleiben einige Filme übrig. Die es entweder nicht gibt oder bei denen entweder der Text in C nicht mit dem in B übereinstimmt oder bei dem die Jahreszahl nicht übereinstimmt. Darum ist die Zeile welche die Spalte D nach C kopiert auskommentiert.
Teste mal (braucht aber ein paar Minuten)
Public Sub SortSpecial()
Dim ialngIndex1 As Long, ialngIndex2 As Long
Dim avntValues As Variant
Dim astrTemp() As String
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Call Range("A:B").Sort(Key1:=Cells(1, 2), Header:=xlYes)
Call Range("C:C").Sort(Key1:=Cells(1, 3), Header:=xlYes)
avntValues = Range(Cells(2, 1), Cells(Rows.Count, 3).End(xlUp)).Value2
For ialngIndex1 = 1 To UBound(avntValues, 1)
For ialngIndex2 = 1 To UBound(avntValues, 1)
If InStr(1, avntValues(ialngIndex1, 3), avntValues(ialngIndex2, 2), vbTextCompare) > 0 Then
astrTemp = Split(avntValues(ialngIndex2, 1), "(")
If InStr(1, avntValues(ialngIndex1, 3), "(" & astrTemp(UBound(astrTemp))) > 0 Then
Call Cells(ialngIndex1 + 1, 3).Cut(Destination:=Cells(ialngIndex2 + 1, 4))
Exit For
End If
End If
Next
Next
'Call Range(Cells(2, 4), Cells(Rows.Count, 4)).Cut(Destination:=Cells(2, 3))
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
Nach dem Durchlauf stehen die sortieren Werte in Spalte D.
Gruß
Nepumuk