+ Reply to Thread
Results 1 to 5 of 5

Sorting rows of data based off a single column for a variable number of entries.

  1. #1
    Registered User
    Join Date
    07-31-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    23

    Sorting rows of data based off a single column for a variable number of entries.

    I am trying to sort rows of data based on an identification number. The amount of entries can change. I can use the record macro function and get this code:
    Please Login or Register  to view this content.
    However, it's messy and depends on the number of entries to be identical each time. Here are some facts that will help:
    1) The data always exists starting in B9. There will always be data in this row.
    2)The data in column B is already stored in an array, but I'm not sure if that'll help. Likewise, all other columns have their data in separate arrays with the same indices for each row.

    I'm having problems with figuring out excel's syntax for sort, but I think if it's possible to clean up the code and select b9 and all values below that (no gaps in file), it should be pretty simple code.

    Thanks for any and all guidance.

  2. #2
    Forum Guru tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Sorting rows of data based off a single column for a variable number of entries.

    soxcrates,

    Give this a try:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    07-31-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Sorting rows of data based off a single column for a variable number of entries.

    Thanks tigeravatar,

    It was able to sort column B great. That's the kind of simplification I was looking for, but is there a way for it to grab all the data in the row and move that data based on how B was sorted?

    Specifically there will be data in column D and/or column G that needs to stay associated with its column B id. The caveat I forgot to mention is columns C, E, and F are blank. I suppose I could change columns D and G to C and D respectively if any changes in code would be significantly more difficult.

  4. #4
    Forum Guru tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Sorting rows of data based off a single column for a variable number of entries.

    The range("A:G") represents which columns will get sorted based on column B
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-31-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Sorting rows of data based off a single column for a variable number of entries.

    Wonderful, works perfectly. Thanks for your help.

+ 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