Random employee assignment to accounts that stops assigning Employees when the count reaches 25

Lisa116

New Member
Joined
Jul 19, 2019
Messages
18
Office Version
  1. 365
Platform
  1. Windows
I use Office 365, and have a sheet with15,000 accounts that need to be assigned to employees. I am randomly assigning employee IDs to each row and once the employee ID is used 25 times the formula needs to exclude the employee ID. I need help excluding that employee ID from the random selection.
1714070035404.png
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Maybe you can make use of this:
MrExcelPlayground22.xlsx
ABCDEF
1Account No.Assigned Emp16Emp List
21GustofJohn15
32GustofFred16
43JohnMary13
54JamieSally14
65JamieJamie16
76GustofGustof16
87John
98Mary
109Jamie
1110John
1211Gustof
1312Mary
1413John
1514Sally
1615Jamie
1716Sally
1817Jamie
1918Mary
2019Gustof
2120John
2221Gustof
2322Gustof
2423John
2524Sally
2625Gustof
2726Mary
2827Mary
Sheet15
Cell Formulas
RangeFormula
A2:A91A2=SEQUENCE(90)
F2:F7F2=COUNTIF(B2:B91,E2:E7)
B2B2=LET(EL,$E$2:$E$7,b,INT(RAND()*ROWS(EL)+1),INDEX(EL,b))
B3:B28B3=LET(z,$D$1,el,$E$2:$E$7,a,B$2:B2,b,COUNTIF(a,el),c,FILTER(el,b<z),d,INT(RAND()*ROWS(c)+1),IFERROR(INDEX(c,d),"Out of Employees"))
Dynamic array formulas.
 
Upvote 0
Thank you so much for your quick response. I like the advise, but I am getting the IFERROR response. Please show me what I am doing wrong. In my first row I have the formula:
LET(A,FILTER(BP7:EP7,BP7:EP7>0),B,COUNTA(BP7:EP7),C,RANDBETWEEN(1,B),D,CHOOSECOLS(A,C),D)

The second row I used what you gave me, with a small adjustment, because my EEIDs are in columns.
LET(M,25,A,FILTER(BP8:EP8,BP8:EP8>0),B,AI$7:AI7,C,COUNTIF(B,A),D,FILTER(A,B<M),E,INT(RAND()*COLUMNS(A)+1),IFERROR(INDEX(D,E),"NO BPA"))

1714089506727.png
 

Attachments

  • 1714089464993.png
    1714089464993.png
    62.2 KB · Views: 2
Upvote 0
Maybe:

LET(M,25,A,FILTER(BP8:EP8,BP8:EP8>0),B,AI$7:AI7,C,COUNTIF(B,A),D,FILTER(A,B<M),E,INT(RAND()*COLUMNS(D)+1),IFERROR(INDEX(D,E),"NO BPA"))

"D" will be smaller than "A", so you might get an index that goes too big. But it should work some of the time (most of the time). If it never works, that is troubling.

What I like about "LET" is that you can diagnose it pretty well. change it to:
LET(M,25,A,FILTER(BP8:EP8,BP8:EP8>0),B,AI$7:AI7,C,COUNTIF(B,A),D,FILTER(A,B<M),E,INT(RAND()*COLUMNS(D)+1),F,IFERROR(INDEX(D,E),"NO BPA"),F)

And then replace that last "F" with all the other variables until the problem becomes obvious.
 
Upvote 0
Good morning and thank you again for your response. I made a few adjustments and now I am getting a number but not the number I am expecting back. I changed the name value D formula to C<M and changed the RAND() to RANDBETWEEN(). Please help me understand why I am getting 11 instead of a number from Columns BP to BU? None of these numbers have been used more than 25 times. I look forward to your guidance!

1714140557083.png
 
Upvote 0
Good morning again! I was able to get the formula to work but on the rows with "NO BPA" there should be one of the numbers to the right of column BP populating the cell. I would understand getting the "NO BPA" later down the sheet. Maybe I am not understand the name value F formula.

1714142178864.png
 
Upvote 0
I think part of the problem is the randbetween instead of rand. It's a good idea, but then multiplying by columns(D) doesn't make sense. And I would randbetween(1,D) not "E". Posting in xl2bb a portion of your stuff might help me with the diagnosing.
 
Upvote 0
Good evening James. Thank you for all of your help. The changes your stated above made the difference. The random is working perfectly. I cannot thank you enough for helping me. Take care.
 
Upvote 0

Forum statistics

Threads
1,215,554
Messages
6,125,487
Members
449,233
Latest member
Deardevil

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