+ Reply to Thread
Results 1 to 4 of 4

How do I sort numbers based on last two digits?

  1. #1
    The Wallaby
    Guest

    How do I sort numbers based on last two digits?

    I am working on a hospital project. Casenotes are stored by a 3 dual digit
    system eg. 23 44 67 with casenotes ending in ** ** 68 and ** ** 66 stored
    adjacent. Get it? I have a load of notes to look up so I need to sort out the
    casenote numbers I have by the last two digits in order to simplify the
    manual search for the notes. Is there any way I could program the Excel list
    I have to sort the last two digits of the casenote numbers into numerical
    order?

  2. #2
    ben
    Guest

    RE: How do I sort numbers based on last two digits?

    Wallaby,

    The following code assumes all your data is in one list and the case
    notes are in the first row, and all data is on sheet1

    sub sort()
    nurec = sheet1.usedrange.rows.count
    for t = 1 to nurec
    for y = 1 to nurec
    casno = right(cells(y,1),2)
    casnonex = right(cells(y+1,1),2)
    if casnonex > casno then goto nexty
    rows(trim(str(y))).copy
    rows(trim(str(nurec+6))).select
    activesheet.paste
    rows(trim(str(y+1))).copy
    rows(trim(str(y))).select
    activesheet.paste
    rows(trim(str(nurec+6))).copy
    rows(trim(str(y+1))).select
    activesheet.paste
    rows(trim(str(nurec+6))).clear
    nexty:
    next y
    next t
    end sub
    note this sub is completely untested and i may have misunderstood your
    criteria, run on a backup copy first

    "The Wallaby" wrote:

    > I am working on a hospital project. Casenotes are stored by a 3 dual digit
    > system eg. 23 44 67 with casenotes ending in ** ** 68 and ** ** 66 stored
    > adjacent. Get it? I have a load of notes to look up so I need to sort out the
    > casenote numbers I have by the last two digits in order to simplify the
    > manual search for the notes. Is there any way I could program the Excel list
    > I have to sort the last two digits of the casenote numbers into numerical
    > order?


  3. #3
    Fredrik Wahlgren
    Guest

    Re: How do I sort numbers based on last two digits?


    "The Wallaby" <The [email protected]> wrote in message
    news:[email protected]...
    > I am working on a hospital project. Casenotes are stored by a 3 dual digit
    > system eg. 23 44 67 with casenotes ending in ** ** 68 and ** ** 66 stored
    > adjacent. Get it? I have a load of notes to look up so I need to sort out

    the
    > casenote numbers I have by the last two digits in order to simplify the
    > manual search for the notes. Is there any way I could program the Excel

    list
    > I have to sort the last two digits of the casenote numbers into numerical
    > order?


    Assuming that your casenotes are in column A, enter =RIGHT(A1,2) in colmun B
    and drag downwards. Select columns A and B and select Data|Sort. Sort on
    column B.

    /Fredrik



  4. #4
    ben
    Guest

    Re: How do I sort numbers based on last two digits?

    I like that solution much better Fredrik, why do i like to do things the hard
    way? :-p

    "Fredrik Wahlgren" wrote:

    >
    > "The Wallaby" <The [email protected]> wrote in message
    > news:[email protected]...
    > > I am working on a hospital project. Casenotes are stored by a 3 dual digit
    > > system eg. 23 44 67 with casenotes ending in ** ** 68 and ** ** 66 stored
    > > adjacent. Get it? I have a load of notes to look up so I need to sort out

    > the
    > > casenote numbers I have by the last two digits in order to simplify the
    > > manual search for the notes. Is there any way I could program the Excel

    > list
    > > I have to sort the last two digits of the casenote numbers into numerical
    > > order?

    >
    > Assuming that your casenotes are in column A, enter =RIGHT(A1,2) in colmun B
    > and drag downwards. Select columns A and B and select Data|Sort. Sort on
    > column B.
    >
    > /Fredrik
    >
    >
    >


+ 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