+ Reply to Thread
Results 1 to 7 of 7

Macro for sorting alpha-numeric data

  1. #1
    Registered User
    Join Date
    07-18-2007
    Location
    US
    Posts
    33

    Macro for sorting alpha-numeric data

    In column A I have alpha-numeric data similar to:

    2
    A1
    3
    A20
    A186
    B4
    B13
    1
    C5
    C3

    And I need to sort them so that they are like:

    1
    2
    3
    A1
    A20
    A186
    B4
    B13
    C3
    C5

    With the numbers first, in ascending order. Then the letters, grouped by letter ascending, and the number following them. But I can't have it where it looks at the first number after the letter (A1,A186,A20). It has to look at the WHOLE number and then sort it.

    TIA
    Last edited by VBA Noob; 12-03-2008 at 03:02 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    1) Is the alpha component always 1 character long?

    2) Do you have a blank couple of columns that you can use as assists. I think you are going to have to separate the alpha and numerics, then sort separately, then recombine.


    rylo

  3. #3
    Registered User
    Join Date
    07-18-2007
    Location
    US
    Posts
    33
    Quote Originally Posted by rylo View Post
    Hi

    1) Is the alpha component always 1 character long?

    2) Do you have a blank couple of columns that you can use as assists. I think you are going to have to separate the alpha and numerics, then sort separately, then recombine.


    rylo
    1) No, it may be 2 or more.

    2) That's ok, I would just need to delete them at the end of the macro.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    If your comfortable using a UDF, you can add this:
    Please Login or Register  to view this content.
    Example usage is =PadNumbers(A1, 3) in a separate column, then sort by that column.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    For the moment, assume you have you data in column A, starting in row 2 (A1 is a heading) and you can use columns B and C as working columns.

    See how this goes.

    Please Login or Register  to view this content.
    rylo

  6. #6
    Registered User
    Join Date
    07-18-2007
    Location
    US
    Posts
    33
    Seems like it worked, thanks.

  7. #7
    Registered User
    Join Date
    08-06-2014
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    3

    Re: Macro for sorting alpha-numeric data

    Quote Originally Posted by rylo View Post
    Hi

    For the moment, assume you have you data in column A, starting in row 2 (A1 is a heading) and you can use columns B and C as working columns.

    See how this goes.

    Please Login or Register  to view this content.
    rylo
    i've data from columns A1:L1
    if i sort data of A1, then data of columns B1 to L1 should be adjusted as per sort of column A
    can you help
    thx

+ 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