Ich habe 4 Tabellen und öchte auf jeder Tabelle auf Knopfdruck das gleiche Makro ausfüllen.
Es sollen einfach die Zeilen 9:2000 erst nach Spalte D und anschliessend nach Spalte C sortiert werden.
Er bricht aber immer beim Apply ab.
Was mache ich falsch?
Sub sortieren()
Rows("9:9").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.ActiveSheet.sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.sort.SortFields.Add Key:= _
Range("D9:D2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.ActiveSheet.sort
.SetRange Range("A9:Q2000")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWorkbook.ActiveSheet.sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.sort.SortFields.Add Key:= _
Range("C9:C1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.ActiveSheet.sort
.SetRange Range("A9:Q2000")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A6").Select
End Sub
Tobiax...