+ Reply to Thread
Results 1 to 5 of 5

special sort sequence

  1. #1
    Registered User
    Join Date
    09-22-2006
    Posts
    4

    special sort sequence

    I have a column I need to sort that uses a alpha-numeric identifier. I've tried creating a special sort sequence but the list is not long enough to contain all the necessary data.
    the column contains the followin data
    1A1~1Z10 (1A1, 1A2...1Z9, 1Z10)
    and continues to
    32A1~32Z10

    the problem with the sort is that is only looks at the 1st character and sorts 1's, and the 10's, then 2's and 20's. I need it to sort 1...32

  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Hi

    If you can provide a sample of your spreadsheet, this would be easier to code. However if this is not possible I would split value in 3 different column
    (ie cola 1, colb b, colc 1) and then I would sort by colb and then cola.

    Good luck
    Denis

  3. #3
    Registered User
    Join Date
    09-22-2006
    Posts
    4

    sort sequence

    I tried seperating the characters in the column but since there are some single digit prefixes and some two digit prefixes it didn't help

    here is a sample section of the spread sheet
    Attached Images Attached Images

  4. #4
    Registered User
    Join Date
    09-22-2006
    Posts
    4

    Sort Sequence

    This may help define it out more



    \1
    Attached Images Attached Images
    Last edited by fwalden; 10-05-2006 at 03:00 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Hi

    Try this code
    Sub separate_numb_char()
    Dim find_letter As String
    flag1 = "NO"
    'insert temp column E
    Columns("E:E").Select
    Selection.Insert Shift:=xlToRight
    rowcount = Cells(Cells.Rows.Count, "d").End(xlUp).Row
    'loop each cell in col d
    For i = 2 To rowcount
    Range("d" & i).Select
    store = ActiveCell.Value
    check_len = Len(store)
    check_len = check_len
    For j = 1 To check_len
    find_letter = Mid(store, check_len - j, 1)
    If find_letter = "A" Or find_letter = "B" Or find_letter = "C" Or find_letter = "D" _
    Or find_letter = "E" Or find_letter = "F" Or find_letter = "G" Or find_letter = "H" _
    Or find_letter = "I" Or find_letter = "J" Or find_letter = "K" Or find_letter = "L" _
    Or find_letter = "M" Or find_letter = "N" Or find_letter = "O" Or find_letter = "P" _
    Or find_letter = "Q" Or find_letter = "R" Or find_letter = "S" Or find_letter = "T" _
    Or find_letter = "U" Or find_letter = "V" Or find_letter = "W" Or find_letter = "X" _
    Or find_letter = "Y" Or find_letter = "Z" And flag1 = "NO" Then

    number1 = (check_len - j)
    flag1 = "YES"
    If check_len = "4" Then
    If number1 = "2" Then
    numb = Left(store, number1 - 1)
    'last_numb = Right(store, number1)
    ActiveCell.Offset(0, 1).Select
    ActiveCell = numb '& find_letter & last_numb
    Else
    numb = Left(store, number1 - 1)
    'last_numb = Right(store, number1 - 1)
    ActiveCell.Offset(0, 1).Select
    ActiveCell = numb '& last_numb
    End If
    End If
    If check_len = "3" Then
    numb = Left(store, number1 - 1)
    'last_numb = Right(store, number1 - 1)
    ActiveCell.Offset(0, 1).Select
    ActiveCell = numb '& find_letter & last_numb
    End If
    GoTo line1:
    End If
    Next j
    line1:
    Next i
    Call sort_cole
    'delete temp column e
    Columns("E:E").Select
    Selection.Delete Shift:=xlToLeft
    End Sub

    Sub sort_cole()
    rowcount = Cells(Cells.Rows.Count, "d").End(xlUp).Row
    Range("a1:" & "g" & rowcount).Select
    Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlYes, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    Range("a1").Select
    End Sub

+ 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