+ Reply to Thread
Results 1 to 4 of 4

Re-Arranging Numbers to be in Chronological Order

  1. #1
    Registered User
    Join Date
    01-07-2012
    Location
    Washington DC, USA
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re-Arranging Numbers to be in Chronological Order

    Attached is a sample spreadsheet where I have numbers that are currently in reverse chronological order (A 8, 6, 4, 2) and I have been informed that they have to be in proper chronological order (A 2, 4, 6, 8). There is a total of 12,000 rows of data, and somewhere between half and a third of it is not formatted properly. I am looking for a way to quickly correct this. Any help would be greatly appreciated on this.



    Chronological Order.xlsx

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Re-Arranging Numbers to be in Chronological Order

    Hi Rlpowers,

    The attached code should sort all values as you expect... I hope. There is a lot of code, so follow these instructions..

    1. Open a copy of your workbook and press ALT+F11 to open the VB Editor. (In case something goes horribly wrong!)
    2. Click Insert > Module
    3. Open the attached text file and copy all of the code
    4. Paste the code into that new module in the VB Editor
    5. Close the VB Editor
    6. Activate the sheet that contains the values you need sorted
    7. Press ALT+F8 to open the Macros dialog
    8. Select the "reorg" macro and click Run

    I wrote the "reorg" macro, and the rest of the code ("QSortInPlace") is from Chip Pearson's site 'Sorting Arrays in VBA' here: http://www.cpearson.com/excel/SortingArrays.aspx

    Hopefully this helps!
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    01-07-2012
    Location
    Washington DC, USA
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Re-Arranging Numbers to be in Chronological Order

    Thank you very much! It worked perfectly!

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Re-Arranging Numbers to be in Chronological Order

    If the numbers in your string data are consistantly numerically descending then this UDF might help.
    Please Login or Register  to view this content.
    Enter in B1
    Please Login or Register  to view this content.
    Drag/Fill Down

    [EDIT]
    Second Loop removed. I've no idea why I thought it was needed, to much beer probably ...
    Attached Files Attached Files
    Last edited by Marcol; 01-28-2012 at 04:33 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

+ 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