Ich bekomme es nicht hin hoffe jemand kann mir helfen.
Wie kann ich die Tabelle Namens "FilmeAnsehen" Spalte C sortieren das sie gleich mit Spalte B sortiert wird ?
Danke
https://www.herber.de/bbs/user/147191.xlsm
Gruß
Oraculix
Code:
[Cc][+][-]
Option Explicit
Public Sub SortSpecial()
Dim ialngIndex As Long, lngRow As Long
Dim avntValues As Variant
Dim objCollection As Collection
Call Range("A:C").Sort(Key1:=Cells(1, 2), Header:=xlYes)
For lngRow = 2 To Cells(Rows.Count, 3).End(xlUp).Row
With Cells(lngRow, 3).Hyperlinks(1)
.TextToDisplay = Replace$(.TextToDisplay, String$(2, Chr$(160)), " ")
End With
Next
avntValues = Range(Cells(2, 1), Cells(Rows.Count, 3).End(xlUp)).Value2
Set objCollection = New Collection
For ialngIndex = 1 To UBound(avntValues, 1)
Call objCollection.Add(Item:=ialngIndex + 1, Key:=Trim$(Split(avntValues(ialngIndex, 3), "(")( _
0)))
Next
On Error Resume Next
For ialngIndex = 1 To UBound(avntValues, 1)
Call Cells(objCollection.Item(Index:=avntValues(ialngIndex, 2)), 3).Cut(Destination:=Cells(ialngIndex _
+ 1, 4))
Next
' Call Range(Cells(2, 4), Cells(Rows.Count, 4)).Cut(Destination:=Cells(2, 3))
Set objCollection = Nothing
End Sub
Ich habe das Zurück kopieren von Spalte D in die Spalte C auskommentiert damit du die Abweichungen siehst.
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.Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen