+ Reply to Thread
Results 1 to 7 of 7

List all possible combinations of 6 IF the sum is between a certain range

  1. #1
    Registered User
    Join Date
    09-22-2015
    Location
    Valparaiso, IN
    MS-Off Ver
    365
    Posts
    4

    List all possible combinations of 6 IF the sum is between a certain range

    I have a list of employees, their salaries and ratings. I need to display all possible combinations of groups of 6 employees but the sum of their salaries needs to be between 49000-50000. If the sums of the salaries are too high or low, i don't want a list to be returned. I then want to return the average rating of each group. Below is my data set and an example of what I am looking for.


    Employee # Salary Rating
    1 12500 95.711
    2 11700 82.1
    3 11000 88.167
    4 10500 85.867
    5 10300 73.05
    6 9800 73.632
    7 9100 76.026
    8 8700 85.806
    9 8500 71.375
    10 8000 77.167
    11 7900 66.333
    12 7800 75.521
    13 7700 60.711
    14 7600 75.019
    15 7500 66.5
    16 7400 68.043
    17 7300 62.87
    18 7300 67.26
    19 7300 69.621
    20 7300 76.357
    21 7200 65.115
    22 7200 62.19
    23 7200 57.85
    24 7100 65.48
    25 7100 59.019
    26 7000 62.457
    27 7000 65.185
    28 6900 72.391
    29 6800 55.138
    30 6700 57.758





    So for example - One group would be Empolyees 1, 6, 27, 28, 29, 30. Their combined salary is 49,700 and their average rating is 69.969
    Another group would be Empolyees 6, 7, 10, 11, 14, 15. Their combined salary is 49,900 and their average rating is 75.446.
    Employees 1-6 won't work because the salary is to high and 25-30 wouldn't work because the salaries are too low.
    So to recap - i want excel to return a list of all possible groups of 6 whose salaries are between 49,000-50,000 and then calculate the average rating of the group.

    Thanks in advance for any help.
    Last edited by jor2511; 09-22-2015 at 10:04 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: List all possible combinations of 6 IF the sum is between a certain range

    Well, this isn't particularly fast, but it will work. Note, there are over 14k combination JUST starting with employee 1. So this will take a while to spit out all 25 levels.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-22-2015
    Location
    Valparaiso, IN
    MS-Off Ver
    365
    Posts
    4

    Re: List all possible combinations of 6 IF the sum is between a certain range

    Thank You so much! This works perfect and is easy to change if I need to. Very much appreciated!

  4. #4
    Registered User
    Join Date
    09-22-2015
    Location
    Valparaiso, IN
    MS-Off Ver
    365
    Posts
    4

    Re: List all possible combinations of 6 IF the sum is between a certain range

    Thank You so much! This works perfect and is easy to change if I need to. Very much appreciated!

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: List all possible combinations of 6 IF the sum is between a certain range

    With a little help from some other gurus, we wrote a version of this macro that is SIGNIFICANTLY faster as it does all the work in memory, then writes out all the data at once at the end. try this:

    Please Login or Register  to view this content.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  6. #6
    Registered User
    Join Date
    09-22-2015
    Location
    Valparaiso, IN
    MS-Off Ver
    365
    Posts
    4

    Re: List all possible combinations of 6 IF the sum is between a certain range

    Wow, that is much faster. Runs in under 30 seconds compared to 3.5 minutes with the other code. I really do appreciate it. Thank You!

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: List all possible combinations of 6 IF the sum is between a certain range

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. List combinations VBA
    By BarstoolProphet in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-07-2015, 07:32 PM
  2. List all combinations from 1 to 45
    By a1b2c3d4e5f6g7 in forum Excel General
    Replies: 4
    Last Post: 07-21-2014, 07:29 AM
  3. Need a list of combinations
    By Iduno in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-18-2013, 11:11 AM
  4. [SOLVED] List all combinations
    By olives in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 02-12-2013, 01:23 AM
  5. Replies: 19
    Last Post: 09-22-2012, 04:58 AM
  6. Replies: 9
    Last Post: 09-16-2012, 04:30 PM
  7. List combinations of a range
    By Steve-in-austin in forum Excel General
    Replies: 6
    Last Post: 05-19-2006, 02:45 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