AW: Sortieren
07.12.2019 21:33:29
Max
Danke erst mal, aber ich suche nach einer VBA-Lösung
Sub Sortieren()
Dim i As Integer
Dim A, B, C, D As Integer 'Flurabstandsklassenanzahl
Dim P As Worksheet
For Each P In Sheets
P.Activate
i = Application.WorksheetFunction.CountA(Rows("3:3"))
'Sortieren nach A,B,C,D
Range(Columns(2), Columns(i)).Select
Application.DeleteCustomList ListNum:=9
Application.AddCustomList ListArray:=Array("A", "B", "C", "D")
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add2 Key:=Range( _
Columns(2), Columns(i)), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
"A,B,C,D", DataOption:=xlSortNormal
With ActiveSheet.Sort
.SetRange Range(Columns(2), Columns(i))
.Header = xlYes
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
Next P
End Sub
Etwas in der Richtung nur bekomme ich hier immer inen Laufzeitfehler.