kann mir bitte jemand sagen, warum das untere Makro die Überschrift und die ersten beiden Zeilen immer ans untere Ende der Datei sortiert? Die Tabelle hat ca. 12.000 Zeilen
schon jetzt vielen Dank für die Mühe.
Sub Daten_eintragen()
Dim iCounter As Long
Application.ScreenUpdating = False
Range("A1").Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlGuess,
_ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
For iCounter = 2 To Cells(65536, 4).End(xlUp).Row
If Cells(iCounter, 4) = Cells(iCounter - 1, 4) Then
Cells(iCounter, 3) = Cells(iCounter - 1, 3)
Else
If Cells(iCounter, 2) <> "" Then
Cells(iCounter, 3) = Cells(iCounter, 2)
Else
Cells(iCounter, 3) = Cells(iCounter + 1, 2)
End If
End If
Next iCounter
Range("A1").Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Application.ScreenUpdating = True
End Sub