Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1708to1712
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Sortieren

Sortieren
17.08.2019 14:13:20
Stephan
Hallo Zusammen,
ich möchte gerne einen Bereich sortieren. Da ich immer wieder Zeilen einfüge (ans Ende oder mittendrin würde ich gerne einen Makro haben der die neuen Zeilen berücksichtigt. Aktuell wird gehtder Makro nur bis Zeile 418. Da ich in meiner Tabelle einige leere Spalten haben muss ich dreimal Range(Selection, Selection.End(xlToRight)) nutzen. Vielleicht gibt es da auch etwas eleganteres.
Grüße
Stephan

Sub Tabelle1_sortieren()
Sheets("Tabelle1").Select
Range("D16").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Tabelle1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Tabelle1").Sort.SortFields.Add Key:=Range( _
"D17:D418"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Tabelle1").Sort.SortFields.Add Key:=Range( _
"E17:E418"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Tabelle1").Sort.SortFields.Add Key:=Range( _
"F17:F418"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Tabelle1").Sort
.SetRange Range("D16:Y418")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Sortieren
17.08.2019 14:22:50
Nepumuk
Hallo Stephan,
das sollte bis zur deiner Rente reichen:
Public Sub Tabelle1_sortieren()
    With ThisWorkbook.Worksheets("Tabelle1")
        .Sort.SortFields.Clear
        .Sort.SortFields.Add Key:=.Range("D17"), SortOn:=xlSortOnValues, _
            Order:=xlAscending, DataOption:=xlSortNormal
        .Sort.SortFields.Add Key:=.Range("E17"), SortOn:=xlSortOnValues, _
            Order:=xlAscending, DataOption:=xlSortNormal
        .Sort.SortFields.Add Key:=.Range("F17"), SortOn:=xlSortOnValues, _
            Order:=xlAscending, DataOption:=xlSortNormal
        .Sort.SetRange .Range(.Cells(16, 4), .Cells(.Rows.Count, 25))
        .Sort.Header = xlYes
        .Sort.MatchCase = False
        .Sort.Orientation = xlTopToBottom
        .Sort.SortMethod = xlPinYin
        .Sort.Apply
    End With
End Sub

Gruß
Nepumuk
Anzeige
AW: Sortieren
17.08.2019 15:26:59
Daniel
also ich bevorzuge ja fürs Sortieren die alte Befehlfolge aus Excel 2003
die funktioniert immer noch und ist etwas einfacher:
With Sheets("Tabelle1")
.Range(.Cells(17, 4), .Cells.SpecialCells(xlcelltypelastcell)).Sort _
Key1:=.Cells(17, 4), order1:=xlascending, _
Key2:=.Cells(17, 5), order2:=xlascending, _
Key3:=.Cells(17, 6), order3:=xlascending, _
header:=xlNo, MatchCase:=false, Orientation:=1
end With
Gruß Daniel
AW: Sortieren
18.08.2019 18:24:25
Stephan
Hallo ihr zwei,
ich danke euch. Schönen Sonntag.
Grüße
Stephan

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige