ich habe folgenden Code geschrieben:
Sub Sortieren()
Dim sTemp As String, sAdr As String
Dim iLastRow As Integer, iLastCol As Integer
sTemp = Sheets("Menü").cBoxSort.Text
iLastRow = Cells(65536, 1).End(xlUp).Row
iLastCol = Cells(19, 1).End(xlToRight).Column
Range(Cells(19, 1), Cells(19, iLastCol)).Find(sTemp, LookIn:=xlValues).Select
sAdr = ActiveCell.Address(rowabsolute:=False, columnabsolute:=False)
Range(Cells(19, 1), Cells(iLastRow, iLastCol)).Select
If Not sAdr = "F19" Then
Selection.Sort Key1:=Range(sAdr), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Else: Selection.Sort Key1:=Range(sAdr), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
End If
Range("A20").Select
End Sub
Zur Erklärung: In den Feldern A19 bis K19 stehen Überschriften, nach den je nach Auswahl die darunter liegenden Daten sortiert werden sollen. Klappt soweit auch, bis auf Feld F19, darunter sind Zeitangaben im Format: 01.05.2004 00:01:10
Sortiere ich manuell, klappt es auch hier. Aber es kommt eine Abfrage, ob ich alle Werte als Zahl behandeln will, oder Text als Text. Es ist aber alles in der Spalte formatiert als "TT.MM.JJJJ hh:mm:ss". Per Code sortiert er aber nicht korrekt auch wenn ich die Spalte als Zahl formatiere.
Dieses "DataOption1:=xlSortTextAsNumbers" scheint nicht zu funktionieren.
Kann mir da jemand weiterhelfen?
Vielen Dank schon mal im Vorraus!
Olaf