I have a data sheet which looks like this, with General Format:
Date |
---|
01.02.2020 |
02.01.2020 |
01.02.2021 |
02.01.2021 |
I need to sort it chronologically and keep the format dd.mm.yyyy . It should work on all systems like German, US etc...
Using this code messes up the sorting (sorting by dd and not chronologically):
Set ws = ActiveWorkbook.Worksheets(1)
ws.Range("A2", ws.Range("A2").End(xlDown)).NumberFormat = "dd.mm.yyyy"
With ws.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SetRange Range("A1", Range("A1").End(xlDown))
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Any ideas, how I can achieve that? Thanks a lot!