+ Reply to Thread
Results 1 to 15 of 15

Random sorting in groups?

  1. #1
    Registered User
    Join Date
    10-23-2008
    Location
    Sweden
    Posts
    92

    Random sorting in groups?

    Hello,

    I have a list like this:
    Sweden
    Italy
    USA
    Russia
    Italy
    Greece
    Australia
    USA
    Italy

    How do I sort this list randomly but still keep the "groups" together?

    The result I want would look something like this:
    Italy
    Italy
    Italy
    Sweden
    Greece
    Australia
    USA
    USA
    Russia

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Random sorting in groups?

    Hi,

    You can create a custom list in Options to sort in whatever order you like. If you don't wish to add a new list, you can sort using an array like this
    Please Login or Register  to view this content.
    Oops- I missed the random part!
    Last edited by xlnitwit; 09-06-2017 at 03:21 AM.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Random sorting in groups?

    hi johandenver. not a vba expert but this works:
    Please Login or Register  to view this content.
    Attached Files Attached Files

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Random sorting in groups?

    Another one :
    Please Login or Register  to view this content.
    Attached Files Attached Files
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  5. #5
    Registered User
    Join Date
    10-23-2008
    Location
    Sweden
    Posts
    92

    Re: Random sorting in groups?

    Thanks, you guys are awesome. Works like a charm.

  6. #6
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Random sorting in groups?

    You are welcome, glad to help.

    Regards

  7. #7
    Registered User
    Join Date
    10-23-2008
    Location
    Sweden
    Posts
    92

    Re: Random sorting in groups?

    I thought I would be able to adapt your code to my project but I can't seem to get it working correctly.

    Would it be possible make the code work for this table:
    before.png

    ...to produce a result like this?
    after.png

    I need to sort by column A as primary, column L as secondary (but sorting for this column needs to be randomized) and column B as third.

    I'd be very grateful for any kind of help with this :-)

  8. #8
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Random sorting in groups?

    There are 3 contributors in this thread, which one is you refer to ? (so the other two don't need to spend their time for creating a program that won't be used)
    Quote Originally Posted by johandenver View Post
    I thought I would be able to adapt your code to my project but I can't seem to get it working correctly.....
    Also, attach the workbook, we cannot work with screenshots.

  9. #9
    Registered User
    Join Date
    10-23-2008
    Location
    Sweden
    Posts
    92

    Re: Random sorting in groups?

    Oh sorry, I was refering to your code, Karedog.

    I've attached the list I'm trying to sort randomly.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-16-2017
    Location
    Tambov, Russia
    MS-Off Ver
    2010
    Posts
    2

    Re: Random sorting in groups?

    Hi!
    Filtered by column L, sorted by column K, sorted by column A. Column B looks empty. It looks like what you wanted?
    Attached Images Attached Images

  11. #11
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Random sorting in groups?

    Maybe :
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    10-23-2008
    Location
    Sweden
    Posts
    92

    Re: Random sorting in groups?

    Thanks, I tried and it seems to only sort on column A and B. The part where it's supposed to randomize and sort by column L does not work I think.

  13. #13
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Random sorting in groups?

    Strange, it is worked for me, as seen on the attached screenshot.
    Attached Images Attached Images
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    10-23-2008
    Location
    Sweden
    Posts
    92

    Re: Random sorting in groups?

    You are right, it does work as intended. Thanks a million, I would never have figured that code out for myself.

  15. #15
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Random sorting in groups?

    You are welcome. Thanks for marking the thread as solved and rep.points.

    Regards

+ 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. Replies: 1
    Last Post: 10-19-2016, 12:22 PM
  2. VBA Macro to generate groups of 3 random numbers without repetition
    By gurunathblessings in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-16-2016, 09:59 AM
  3. Making random groups of students, no repeat classes
    By philgolf in forum Excel General
    Replies: 0
    Last Post: 08-26-2014, 09:35 AM
  4. Creating random groups of students with no repeats
    By philgolf in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-25-2014, 02:09 PM
  5. Random groups of students
    By ILIASD in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-16-2014, 05:24 AM
  6. Random and Unique Groups
    By rosslo189 in forum Excel General
    Replies: 1
    Last Post: 05-14-2011, 05:55 PM
  7. [SOLVED] How do I generate non-recurring random numbers to assign groups?
    By hkoehnk in forum Excel General
    Replies: 1
    Last Post: 09-12-2005, 04:05 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