Any body knows how to sort:
A2,A1,A3,A21,A31,A25 to be A1,A2,A3,A21,A25,A31 ??
Currently the result I got was A1,A2,A21,A25,A3,A31.
Thanks a million.
Any body knows how to sort:
A2,A1,A3,A21,A31,A25 to be A1,A2,A3,A21,A25,A31 ??
Currently the result I got was A1,A2,A21,A25,A3,A31.
Thanks a million.
You can only achieve your result by making A1, A2, A3 = A01,A02,A03.
"broogle" wrote:
> Any body knows how to sort:
>
> A2,A1,A3,A21,A31,A25 to be A1,A2,A3,A21,A25,A31 ??
> Currently the result I got was A1,A2,A21,A25,A3,A31.
>
> Thanks a million.
>
>
You could try this which adds a column, adds leading 0 (zero) to the data
and places in the added column, sorts it and deletes column. It assumes
original data to be sorted is in column A and that digits lie between 1 and
99 i.e A1 to A99.
Sub Sort()
Columns(1).Insert
ilastrow = Cells(Rows.Count, "B").End(xlUp).Row ' Was originally A
For i = 2 To ilastrow
Cells(i, "A") = Left(Cells(i, "B"), 1) & Format(Right(Cells(i, "B"),
Len(Cells(i, "B")) - 1), "00") ' Add leading zero
Next i
Range("A2:Z" & ilastrow).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Columns(1).Delete
End Sub
HTH
"Toppers" wrote:
> You can only achieve your result by making A1, A2, A3 = A01,A02,A03.
>
> "broogle" wrote:
>
> > Any body knows how to sort:
> >
> > A2,A1,A3,A21,A31,A25 to be A1,A2,A3,A21,A25,A31 ??
> > Currently the result I got was A1,A2,A21,A25,A3,A31.
> >
> > Thanks a million.
> >
> >
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks