+ Reply to Thread
Results 1 to 3 of 3

Sorting problem

  1. #1
    broogle
    Guest

    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. #2
    Toppers
    Guest

    RE: 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. #3
    Toppers
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1