Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting problem
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting problem
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting problem
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
sorting problem | Excel Discussion (Misc queries) | |||
Sorting problem, need some help | Excel Worksheet Functions | |||
SORTING PROBLEM | Excel Worksheet Functions | |||
Sorting problem | Excel Discussion (Misc queries) | |||
Sorting problem | Excel Discussion (Misc queries) |