+ Reply to Thread
Results 1 to 7 of 7

Sort rows in groups/set of 3 rows.

Hybrid View

  1. #1
    Registered User
    Join Date
    10-15-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    10

    Sort rows in groups/set of 3 rows.

    Hi.

    I hope someone in her is able to help me.

    I need a marco that sort rows in set of 3 rows

    So row 5 - 7 and the values in them belong together as 1 set, row 8 - 10 and the values in them belong together as 1 set and so on.
    The values to sort by is in column A, and in the 1'st row of the row set.

    So for the 1'st set (Row 5 - 7), then values to sort by is in cell A5, and for the 2'nd set (Row 8 - 10), the value to sort by is in cell A8....

    I know that is properbly not easy to code, but i hope it is possible.

    Thanks.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,108

    Re: Sort rows in groups/set of 3 rows.

    A macro would, I guess, need to "pre-process" the data. That is, add the key field, for example A5, to the block and add a sequence number, 1,2,3, to the rows. You could then sort sequence number within key field.

    So, I think it's do-able. Just 3 stages: add the sequencing information, normal sort and delete sequencing information.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-15-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Sort rows in groups/set of 3 rows.

    Hi TMShucks.

    Do you happen to know how to do this?

    BR
    Søren

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,108

    Re: Sort rows in groups/set of 3 rows.

    I could probably work it out. What would you have me do it with? Other than your description, I have no idea what your data looks like and, therefore, what might and might not work.

    I suggest that you post a sample workbook.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    10-15-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Sort rows in groups/set of 3 rows.

    Hi TMS.

    I attached a sample of how my sheet and data looks like.

    I hope that will do, and you are able to help me.

    Thanks in advance.

    Br.
    Søren.
    Attached Files Attached Files

  6. #6
    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: Sort rows in groups/set of 3 rows.

    This workbook does as I thought you needed, with a formula rather than VBa, based on post #1.
    I'm not clear from your sample in post #5 as to what needs sorting.

    The formula in B2 is a CSE array and must be confirmed with Ctrl+Shift+Enter, not just Enter, before dragging down.
    Formula: copy to clipboard
    =INDEX(A:A,SUMPRODUCT(--(INDEX(IF(INDEX(INT(ROW($3:$17)/3),,)=INT(ROW(A3)/3),$A$2:$A$16,""),,)>=INDEX(IF(INDEX(INT(ROW($3:$17)/3),,)=INT(ROW(A3)/3),$A$2:$A$16,""),ROWS($2:2),)))+3*INT(ROWS($2:4)/3)-2)

    This sorts the groups of 3 from Z-A, change the operator >= to <= to reverse the sorting to A-Z.
    Attached Files Attached Files
    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.

  7. #7
    Registered User
    Join Date
    10-15-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Sort rows in groups/set of 3 rows.

    Hi Marcol.

    I am not sure how to use this, but let me try to explain what i use the Excel for.

    I use the excel to keep track of what is going in and what is going out form each customer.
    Each customer can have several item number. Each item number owns 3 rows (IN, OUT, SALDO) = 1 Row Set.
    In the first row of a set, the Cust. no (Customer Number) Cust Name (Customer Name) is entered.

    As each customer can add new items to the list, i will add a new row set ( = 3 Row), after the last used row set, and enter the data accordingly to the custmer and iteme number.
    For the overview purpos, I then need to be able to sore the row set, so all row set for custmer "A" is listend under eachother, and the customer "B" and so on.

    I hope it makes sence?

    Br.
    Søren

+ 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