I'm building a macro that sort ascending/descending a range of cells according to its values. The problem is that it is not working with the following data:
11_NR-10.pdf 16_NR-10.pdf 1_NR-10.pdf 6_NR-10.pdf
When I try to sort, I get the following result:
1_NR-10.pdf 11_NR-10.pdf 16_NR-10.pdf 6_NR-10.pdf
Does someone knows how to help me?
Code:
Dim xlSort As XlSortOrder
Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
If (.Range("A3").Value > .Range("A" & CStr(LastRow))) Then
xlSort = xlAscending
Else
xlSort = xlDescending
End If
.Range("A3:A" & LastRow).Sort Key1:=.Range("A3"), Order1:=xlSort, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
ActiveWorkbook.Save