Excel 2010, windows7; After performing the sort shown below, why does the data end up at the BOTTOM of the sort range rather than at the top where it started and where it belongs? The first cell was in the upper left cell to begin with and after the sort it ends up in the bottom left cell. Whether I tell it to do the sort in ascending or descending order, the data end of at the bottom left of the worksheet. The data is sorting on text strings (not numbers). This seems to happen on occasion (in this and other worksheets) with different sorts described in the same way. VERY frustrating.
Sub Sort_Projects_Inspection_Times()
'
' Sort_Projects_Inspection_Times Macro
Range("J4:AJ1406").Select
ActiveWorkbook.Worksheets("Inspection Time").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Inspection Time").Sort.SortFields.Add Key:=Range( _
"J5:J1406"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Inspection Time").Sort.SortFields.Add Key:=Range( _
"L5:L1406"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Inspection Time").Sort
.SetRange Range("J4:AJ1406")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub Sort_Projects_Inspection_Times()
'
' Sort_Projects_Inspection_Times Macro
Range("J4:AJ1406").Select
ActiveWorkbook.Worksheets("Inspection Time").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Inspection Time").Sort.SortFields.Add Key:=Range( _
"J5:J1406"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Inspection Time").Sort.SortFields.Add Key:=Range( _
"L5:L1406"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Inspection Time").Sort
.SetRange Range("J4:AJ1406")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub