Hallo Erik,
Post by Erik HarrenOk, Bleistift gefällig: Sortiert werden die Spalten über das Ergebnis
(eher sogar Datum) in Zeile 3.
Zeile Spalten
A B C
1 AA CD BA
2 egal egal2 egal3
3 4711 0815 007
Zeile Spalten
A B C
1 BA CD AA
2 egal3 egal2 egal
3 007 0815 4711
das Beispiel war schon sehr hilfreich...
Probiers mal mit folgender Prozedur:
Public Sub SpaltenSortieren()
Dim rngBereich As Range
Dim lngSuchZeile As Long
Dim intCol As Integer
Dim intCount As Integer
Dim varColumns As Variant
lngSuchZeile = 3
Application.ScreenUpdating = False
With ActiveSheet
Set rngBereich = Intersect(.UsedRange, .Columns("A:C"))
Set rngBereich = rngBereich.Cells(lngSuchZeile, 1) _
.Resize(1, rngBereich.Columns.Count)
ReDim varColumns(rngBereich.Columns.Count - 1)
For intCount = 1 To rngBereich.Columns.Count
intCol = rngBereich.Find(Application.Min(rngBereich), _
LookAt:=xlWhole).Column
varColumns(intCount - 1) = .Columns(intCol).Value
.Columns(intCol).ClearContents
Next intCount
For intCount = 1 To rngBereich.Columns.Count
.Columns(intCount).Value = varColumns(intCount - 1)
Next intCount
End With
Application.ScreenUpdating = True
End Sub
--
Mit freundlichen Grüssen
Melanie Breden
- Microsoft MVP für Excel -
http://excel.codebooks.de (Das Excel-VBA Codebook)
#Excel-Auftragsprogrammierung#