Sortierschleife bricht nicht ab
15.09.2014 11:45:13
Maike
ich habe in einem Excelblatt in zwölf Spalten ungeordnete Werte und gebe diese in rehten Nachbarspalten sortiert aus. Weil immer wieder Werte hinzukommen, fängt die Prozedur in der Zeile an, in der bis dahin noh keine Sortierung erfolgte. Doch der Kollege, der mir das Makro erstellt hatte ist nicht mehr greifbar und mein kleiner Bruder hat den Code kaputt gespielt.
Könnt Ihr mir helfen, dass dieser Code wieder in Excel 2010 funktioniert?
Private Sub CommandButton1_Click()
Dim Lz As Long
Dim iRow As Variant
iRow = 2
Do While Cells(iRow, 4) "" Or Cells(iRow, 4) 0
Lz = Cells(Rows.Count, 15).End(xlUp).Row + 1
Range(Cells(Lz, 1), Cells(Lz, 12)).Copy Destination:=Range(Cells(Lz, 13), Cells(Lz, 24))
Range(Cells(Lz, 13), Cells(Lz, 24)).Select
Selection.Sort Key1:=Cells(Lz, 12), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
If Cells(iRow, 4) = "" Or Cells(iRow, 4) = 0 Then Exit Do
iRow = iRow + 1
Loop