=ROUNDUP(RANK($C27,Rando)/Sizes,0) FORMULA

samyscraps01

Board Regular
Joined
Jul 6, 2017
Messages
58
I tried the formula below
=ROUNDUP(RANK($C27,Rando)/Sizes,0) and it works great for a list of people. I need this formula to work for a group of employees rather than a list of names. My chart below shows a group of employees in each department. So 42 represents one department, 19 another group of employees in another dept, and so forth. I want the formula to group together as evenly as possible all the departments and distribute them evenly into 6 main groups to be disbursed amongst 6 leaders. This is more than just taking the total of all the employees and dividing them into six even groups. I need as many departments grouped as evenly as possible into six buckets. Is there a way to do this? Even with another formula. I tried this formula with a list of employees and it worked really well but when I applied it to the EE's in Column B I did not get the same results.
[TABLE="width: 566"]
<tbody>[TR]
[TD]Dept No.
[/TD]
[TD]EE
[/TD]
[TD]Random
[/TD]
[TD]Buckets
[/TD]
[TD]Name List
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD] 91230
[/TD]
[TD]42
[/TD]
[TD]0.583587226
[/TD]
[TD]3
[/TD]
[TD]Sizes
[/TD]
[TD]6
[/TD]
[/TR]
[TR]
[TD]91231
[/TD]
[TD]19
[/TD]
[TD]0.829519086
[/TD]
[TD]1
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91232
[/TD]
[TD]35
[/TD]
[TD]0.393358531
[/TD]
[TD]3
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91233
[/TD]
[TD]57
[/TD]
[TD]0.775741312
[/TD]
[TD]2
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91234
[/TD]
[TD]25
[/TD]
[TD]0.141453984
[/TD]
[TD]4
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91235
[/TD]
[TD]23
[/TD]
[TD]0.023805453
[/TD]
[TD]4
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91236
[/TD]
[TD]39
[/TD]
[TD]0.511275187
[/TD]
[TD]3
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91237
[/TD]
[TD]47
[/TD]
[TD]0.212964913
[/TD]
[TD]4
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91238
[/TD]
[TD]7
[/TD]
[TD]0.23715932
[/TD]
[TD]4
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91239
[/TD]
[TD]3
[/TD]
[TD]0.774636135
[/TD]
[TD]2
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91240
[/TD]
[TD]18
[/TD]
[TD]0.52070436
[/TD]
[TD]3
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91241
[/TD]
[TD]17
[/TD]
[TD]0.300847994
[/TD]
[TD]4
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91242
[/TD]
[TD]2
[/TD]
[TD]0.841505214
[/TD]
[TD]1
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91243
[/TD]
[TD]36
[/TD]
[TD]0.789073292
[/TD]
[TD]1
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91244
[/TD]
[TD]101
[/TD]
[TD]0.825132871
[/TD]
[TD]1
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91245
[/TD]
[TD]13
[/TD]
[TD]0.886795114
[/TD]
[TD]1
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91246
[/TD]
[TD]15
[/TD]
[TD]0.704440553
[/TD]
[TD]2
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91247
[/TD]
[TD]28
[/TD]
[TD]0.733682216
[/TD]
[TD]2
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91248
[/TD]
[TD]4
[/TD]
[TD]0.280399365
[/TD]
[TD]4
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91249
[/TD]
[TD]48
[/TD]
[TD]0.326471943
[/TD]
[TD]3
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91250
[/TD]
[TD]1
[/TD]
[TD]0.576338148
[/TD]
[TD]3
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91251
[/TD]
[TD]12
[/TD]
[TD]0.695422989
[/TD]
[TD]2
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91252
[/TD]
[TD]21
[/TD]
[TD]0.676249387
[/TD]
[TD]2
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
[TR]
[TD]91253
[/TD]
[TD]14
[/TD]
[TD]0.857909903
[/TD]
[TD]1
[/TD]
[TD="colspan: 2"]
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
...group together as evenly as possible all the departments and distribute them evenly into 6 main groups...

What exactly does this mean ?

What criteria do you want to use to group departments together ?

Can you give us a worked example of what the results should be, with that sample data ?
And explain how you arrived at those results ?
 
Upvote 0
Thank you Gerald for responding. I have been up since midnight trying to troubleshoot this problem.

MGR DEPT. NAME DEPT. NO. # OF EMP
[TABLE="width: 547"]
<tbody>[TR]
[TD]SAM
[/TD]
[TD]PAYROLL
[/TD]
[TD]90010
[/TD]
[TD]26
[/TD]
[/TR]
[TR]
[TD]SAM
[/TD]
[TD]HR
[/TD]
[TD]90028
[/TD]
[TD]8
[/TD]
[/TR]
[TR]
[TD]RALPH
[/TD]
[TD]FACILITIES
[/TD]
[TD]90016
[/TD]
[TD]36
[/TD]
[/TR]
[TR]
[TD]LYNN
[/TD]
[TD]CARDIO
[/TD]
[TD]90037
[/TD]
[TD]2
[/TD]
[/TR]
[TR]
[TD]LYNN
[/TD]
[TD]LAB
[/TD]
[TD]90039
[/TD]
[TD]8
[/TD]
[/TR]
[TR]
[TD]LYNN
[/TD]
[TD]EDUCATION
[/TD]
[TD]90020
[/TD]
[TD]3
[/TD]
[/TR]
</tbody>[/TABLE]

Sorry, let me see if I can explain a little better. I was tasked with taking a list of Managers (Column A), and trying to group them together into 6 different groups. The catch is that each manager has multiple departments (column B /C) under their scope and furthermore the number of employees varies in each department. I need to distribute this list to 6 different leaders, and each leader wants to get a list of close to the same amount as the next leader. They would like to keep as many as the same managers in each bucket so they aren’t splitting managers.

Does that make sense? This is complicated because the number of employees varies. I got a decent formula but it did not give me an even split and same managers were distributed in multiple buckets. I can’t have that. Essentially each leader prefers to work with the same set of managers and still retain an even amount of employees.

Is this possible?
 
Upvote 0
Well the data in post #3 looks different to the data in post #1 , because the department numbers are all different.

What would really help is to show in a single post, a sample of the source data, AND what the results should be FOR THAT source data.

I think I get roughly what you are trying to do, but I guess there are some specific criteria here that you want to work with and I'm not getting those.
 
Upvote 0
Post 1 was me trying to explain this and clearly I failed miserably. Let’s stick with Post 3, I think that’s a little more straightforward.

[TABLE="width: 547"]
<tbody>[TR]
[TD]MGR[/TD]
[TD]DEPT. NAME[/TD]
[TD]DEPT. NO[/TD]
[TD]# OF EMP[/TD]
[/TR]
[TR]
[TD]SAM[/TD]
[TD]PAYROLL[/TD]
[TD]90010[/TD]
[TD]26[/TD]
[/TR]
[TR]
[TD]SAM[/TD]
[TD]HR[/TD]
[TD]90028[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]RALPH[/TD]
[TD]FACILITIES[/TD]
[TD]90016[/TD]
[TD]36[/TD]
[/TR]
[TR]
[TD]LYNN[/TD]
[TD]CARDIO[/TD]
[TD]90037[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]LYNN[/TD]
[TD]LAB[/TD]
[TD]90039[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]LYNN[/TD]
[TD]EDUCATION[/TD]
[TD]90020[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Ideally, I would like the results to look something like this:

Bucket 1 :
Sam - 26
Sam – 8
Total: 34

Bucket 2:
Ralph – 36
Total: 36

Bucket 3:
Lynn -2
Lynn -8
Lynn -3
Total: 13

(Bucket 3 -this is just a sample, Ideally I would like this bucket to contain about the same as the others). For the sake of it, let’s say the total here was 32 instead of 13 as outlined above in the chart. This means that all three buckets, contain about the same number of employees without separating the managers into different buckets. The goal is for the 6 leaders to work with the same group of managers. So, leader 1 would get Bucket 1. What they don’t want is to be working with Sam or any other manager appearing in different buckets, because that means they will be under different leaders. The idea is to keep them in the same buckets while still maintaining an equal or close to equal employee count in each bucket.

If this helps my total employees add up to 1240, and I have 18 different managers. I need 6 different buckets with roughly or as close as possible to same distribution of employees in each bucket. I’ve tried different formulas and I never get an even amount in the buckets or even approximate. I can work with close ranges, eg. 160, 165, 163 or something to that effect but I get stuff like 50, 175, 10, random stuff. That won’t work.

Does this make more sense?

Thank you for your help and your patience.
 
Last edited:
Upvote 0
If your source data already looks like the top table in post #5 , then I don't see what the challenge is . . . it's already been divided up into manager bundles.

Am I missing something ?
 
Upvote 0
What your seeing is manual and I have a lot of data. There are over 1200 employees, I only included a sample of what my source data looks like and you said to give you an idea of what kind of results i'm looking for. There is too much data to do this manually, can it be done with a formula? I guess i'm getting very skeptical that this can be done. If I do this manually it will take me forever moving employees around to get six even buckets while ensuring that the managers are the same in each bucket.

Does this make sense?
 
Upvote 0
Confused, Please upload a screenshot of your workings to get an idea.
 
Upvote 0
OK so you've got 1,200 employees.
Imagine instead that you had only 20 employees, and let's say 3 or 4 managers.
What would the data look like for those 20 employees ?
How would you allocate them to buckets ?
Post the data for all 20 employees as it would look at the start, and then post the results you want to see.
 
Upvote 0
If I understand correctly, you want to assign 18 managers to 6 buckets such that the number of employees per bucket is roughly equal. This really can't be done with formulas. What you're asking is to calculate hundreds, thousands, up to 6^18 (101,559,956,668,416) combinations and find the "best" combination. A pretty tall order. Possibly your best option is to use Solver. Set up your worksheet like this:

ABCDEFGHIJKLMNOPQ
MGRDEPT. NAMEDEPT. NO# OF EMPManager# of EmpsGroup# of groupsGroup
SAMPAYROLLSamCount
SAMHRRalph
RALPHFACILITIESLynnMax count - min count
LYNNCARDIOAl
LYNNLABBelle
LYNNEDUCATIONClarisse
BelleDan
FredEd
EdFred
DanGayle
Clarisse
Al
Dan
Fred
Gayle
Al
Al
Belle
Ed

<tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: right"]1[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]6[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]90010[/TD]
[TD="align: right"]26[/TD]
[TD="align: right"][/TD]

[TD="align: right"]34[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"]6[/TD]

[TD="align: right"]46[/TD]
[TD="align: right"]76[/TD]
[TD="align: right"]35[/TD]
[TD="align: right"]106[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]19[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]90028[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"][/TD]

[TD="align: right"]36[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]90016[/TD]
[TD="align: right"]36[/TD]
[TD="align: right"][/TD]

[TD="align: right"]13[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]90037[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]

[TD="align: right"]81[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]87[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]6[/TD]

[TD="align: right"]90039[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"][/TD]

[TD="align: right"]30[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]

[TD="align: right"]90020[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]

[TD="align: right"]19[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]27[/TD]
[TD="align: right"][/TD]

[TD="align: right"]12[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]9[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]

[TD="align: right"]40[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]10[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]22[/TD]
[TD="align: right"][/TD]

[TD="align: right"]22[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]11[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]

[TD="align: right"]25[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]12[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]19[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]13[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]25[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]14[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]15[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]19[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]16[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]25[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]17[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]29[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]18[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]27[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]19[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]20[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]18[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet6

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]G2[/TH]
[TD="align: left"]=SUMIF(A:A,F2,D:D)[/TD]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]L2[/TH]
[TD="align: left"]=SUMIF($H:$H,L1,$G:$H)[/TD]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]K5[/TH]
[TD="align: left"]=MAX(L2:Q2)-MIN(L2:Q2)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]



I added several more managers to test with, since with only 3 managers, there are very few options. Put the complete list of managers in column F. Put the G2 formula in and drag down. Then column H will be the group that the manager will be assigned to. For now, just randomly put values in the list. Fill out J1:K2 as shown. Put 1-6 in L1:Q1. Put the L2 formula in and drag to the right. Finally, put the K4 heading in, and the K5 formula.

Group 4 has 106 employees, and 6 has 19, for a difference of 87 (K5). Not very close. So let's try Solver. Solver is included with Excel, but it's not installed by default. Make sure you have it installed by clicking on File > Options > Add-ins > On the bottom where it says "Excel Add-ins" click Go... > Check the Solver Add-in box > OK. Now go to the Data tab and click Solver on the far right.

It'll open up a dialog box. Enter the parameters as follows:

Set Objective: $K$5
To: Min
By Changing Variable Cells: $H$2:$H$11
Subject to the Constraints:
$H$2:$H$11<=$J$2
$H$2:$H$11=integer
$H$2:$H$11>=1
Select a Solving Method: Evolutionary

and click Solve. You'll have to change the $H$2:$H$11 range to be the full list of your managers. It'll run for a few minutes and come up with its best guess for a solution. Also keep in mind that the solution is often dependent on the initial conditions. So if you don't get an answer close enough to your liking, you can change the starting values in H to all 1's, or all 6's, and try again. You might get a better solution.

If you still can't get a good enough solution, there are a few other option. First, we can come up with a somewhat more complicated model which allows some departments to go to different groups, even though the manager is the same. We'd have to add a parameter that we also want to minimize so that happens as infrequently as possible.

Another option which may or may not work any better is we could write a macro that randomly assigns managers to groups, checks the "goodness" of the solution, and keeps the best. After a few thousand iterations, it might find something decent. But it may not. There over over 100 TRILLION options, and we just can't check them all.

There are also algorithms designed to do what you ask, like here:

https://www.geeksforgeeks.org/partition-set-k-subsets-equal-sum/

Unfortunately, I don't have time to adapt this algorithm for your situation. But there are possibilities. Good luck!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,930
Members
452,367
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top