Hi,
I used to have time/date data coming in with m/d/yyyy h:mm AM/PM format and now it has a comma in the middle of it (m/d/yyyy, h:mm AM/PM) and after running my code, it is not sorting properly. Any idea what's wrong?
I used to have time/date data coming in with m/d/yyyy h:mm AM/PM format and now it has a comma in the middle of it (m/d/yyyy, h:mm AM/PM) and after running my code, it is not sorting properly. Any idea what's wrong?
Code:
' Find which column "Local Start Time" appears in
Rows("1:1").Find(What:="Local Start Time", After:=Range("A1"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
sortAdd = ActiveCell.Address(0, 0)
' Convert entries in Date column to valid dates
Columns(ActiveCell.Column).TextToColumns Destination:=Range(sortAdd), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 3), TrailingMinusNumbers:=True
' Format columns
Columns(ActiveCell.Column).NumberFormat = "[$-409]m/d/yy h:mm AM/PM;@"
' Set sort range by using current region
Range("A1").CurrentRegion.Sort _
Key1:=Range(sortAdd), Order1:=xlAscending, Header:=xlYes