+ Reply to Thread
Results 1 to 6 of 6

Sorting while grouping

  1. #1
    Registered User
    Join Date
    12-10-2013
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    8

    Sorting while grouping

    Hello,

    I have a 3000 line excel. I have 1 column that contains order numbers (Order Number) and another column that contains item numbers (Vendor SKU).
    I need to sort my excel by item number, but I need to keep all the same orders together, so basically if I have the same item number 100 times on the excel, I need them to come one after the other with the exception of the other item numbers in the same order.
    Example;
    Order # Item #
    123 ABC
    123 ABD
    124 ABE
    125 ABC
    126 ABC
    I need the results to be;
    123 ABC
    123 ABD
    125 ABC
    126 ABC
    124 ABE

    Please help!

    Thanks in advance
    Attached Files Attached Files
    Last edited by TamiT; 08-24-2015 at 11:47 AM. Reason: Added attachement

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Sorting while grouping

    Use sort dialog box (not just A->Z or Z->A buttoms) and there you can declare several keys of sorting, so as a first key use orderNo and second key ItemNo
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    12-10-2013
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Sorting while grouping

    Thank you but just sorting will not do the trick. If I sort using sort 1 and 2 as you suggested, the excel will be sorted by the orderno numerically and then by itemno which is not what im trying to do. I need to sort by itemno but I need the orderno to stay together. So if throughout the excel I have the same itemno 100 times I would like them all to be one after the other with the exception of the other itemno in the same orderno. Hope that makes sense

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Sorting while grouping

    Just to make sure - you added an attachment, but there is just one list. I assume it is current state - what would be expected result? Of course whole list is too long to do it manually, so use some 20 top rows and rearrange their order.

  5. #5
    Registered User
    Join Date
    12-10-2013
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Sorting while grouping

    Kaper, I am attaching the file again, but in sheet 1 I am showing my desired results.
    Thanks in advance for your help!
    Attached Files Attached Files
    Last edited by TamiT; 08-24-2015 at 12:29 PM.

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Sorting while grouping

    OK. So it is a bit more complicated - we will need three keys sorting. See attachement and brief explanation:

    I made a list of all vendors SKUs (copied column D into J, removed duplicates, sorted ascending) and assigned them numbers 1...361 (there is 361 unique SKUs) in column K.

    Then in F2 I wrote number for this particular vendor SKU number
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and in G2 smallest number for any vendor SKU in given orderNo (array formula *):
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and copied both formulas down

    Now the range A1:G3520 has to be sorted on 3 keys: smallest vendor SKU number for given order, order number, vendor SKU number (see picture - sort dialog is in Polish, but elements are located the same way in any national/international version of Excel).
    Of course once rady you can get rid of all columns F:K


    *) ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    Attached Images Attached Images
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Sorting Data and Grouping
    By Forex-Forex in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2014, 05:19 PM
  2. [SOLVED] Sorting then grouping
    By gpowell in forum Excel General
    Replies: 6
    Last Post: 10-22-2013, 06:08 PM
  3. Automated Sorting and Grouping VBA
    By Pivo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-17-2013, 04:04 AM
  4. Help with grouping/sorting
    By ceverett in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-26-2011, 04:00 PM
  5. Excel 2007 : Grouping and Sorting
    By iPaprika in forum Excel General
    Replies: 0
    Last Post: 01-26-2011, 03:49 PM
  6. Sorting/grouping cells
    By kryt0n in forum Excel General
    Replies: 3
    Last Post: 07-27-2010, 06:55 AM
  7. Grouping and Sorting Help!!!!
    By computerjunkie in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-26-2007, 11:35 AM
  8. grouping and sorting data
    By mb7q in forum Excel General
    Replies: 0
    Last Post: 03-30-2006, 03:35 PM

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