Gruppe
Allgemein
Problem
Wie kann ich mehrere nebeneinanderliegende Spalten sortieren?
StandardModule: basMain
Sub ColumnSort()
Dim wks As Worksheet
Dim iCol As Integer, iRow As Integer
Application.ScreenUpdating = False
Set wks = ActiveSheet
Workbooks.Add
iRow = 1
For iCol = 1 To 9 Step 2
Range(Cells(iRow, 1), Cells(iRow + 39, 1)).Value = _
wks.Range(wks.Cells(3, iCol), wks.Cells(42, iCol)).Value
iRow = iRow + 40
Next iCol
Range("A1").Sort _
key1:=Range("A1"), order1:=xlAscending, header:=xlNo
iRow = 1
For iCol = 1 To 9 Step 2
wks.Range(wks.Cells(3, iCol), wks.Cells(42, iCol)).Value = _
Range(Cells(iRow, 1), Cells(iRow + 40, 1)).Value
iRow = iRow + 40
Next iCol
ActiveWorkbook.Close savechanges:=False
Application.ScreenUpdating = True
End Sub