Formula to divide out limited resources (marbles) to a group that wants more than available

superskid

Board Regular
Joined
Aug 25, 2006
Messages
160
[FONT=&quot]I need a formula in column D that will give everyone their marble allocation based on how many they want, and their score.[/FONT]
[FONT=&quot]Column A: Users Name Column B: How many marbles each person wants in a perfect scenario Column C: Their score or ranking within the group (higher score gets more) Column D: Here is where I want to input the formula, drag down and get the number[/FONT]
[FONT=&quot]Variable: Marbles available: This is how many I can hand out, so total of column D needs to equal this Max Marbles per person: The most that any 1 person can be assigned Min Marbles per person: The amount of marbles the last person would get Top X get Max: If 3 is typed in here then the top 3 scores would get 20 then it would drop from there Marble difference per person: This is a formula that would say how much less then the person above you, you get after the top 3. So maybe each ranking after the top 3 the marbles assigned drops by 0.6 in order to end at the minimum number[/FONT]
[FONT=&quot]Notes: If someone's assigned marbles is more then they want it needs to default them to them to their wanted amount and divide the rest up between everyone else not in the top 3[/FONT]
[FONT=&quot]If people have the same score their allocation should be the same. It would only be different if one of the people want less then what their allocation would be.[/FONT]
[FONT=&quot]Screenshot:[/FONT]
[FONT=&quot]
Z1w7jGX.png
[/FONT]
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
This looks to be too complicated to do with formulas. Probably why you haven't gotten any responses so far. Even with VBA it's tricky. However, I think I can picture how to do it. I'm going to be away for a few days. If you haven't gotten an answer when I get back, I'll take a shot at a VBA macro for you.
 
Upvote 0
This looks to be too complicated to do with formulas. Probably why you haven't gotten any responses so far. Even with VBA it's tricky. However, I think I can picture how to do it. I'm going to be away for a few days. If you haven't gotten an answer when I get back, I'll take a shot at a VBA macro for you.

Greatly appreciated, I have plugged away at this for weeks and can't quite get it.
 
Upvote 0
Turns out that you can do this with a formula:

ABCDEFGH
1NameMarbles WantedScoreMarbles AssignedVariables
2Billy5010020xMarbles Available100
3Marry508512.91695Max Marbles per person20
4Douglas658616.98959Min Marbles per person0.1
5Mark209020xTop X get Max3
6Ben3500.455892Marble difference per rank
7Tom20251.519641
8Wayne4011020x
9Vicky30867.841349
10Ales7130.276575
11
12Totals285100

<tbody>
</tbody>
Sheet5

Array Formulas
CellFormula
D2{=IF(C2>=LARGE($C$2:$C$10,$H$5),MIN(B2,$H$3),MIN($H$3,B2*C2/MAX($C$2:$C$10)*($H$2-SUM(IF($C$2:$C$10>=LARGE($C$2:$C$10,$H$5),IF($B$2:$B$10>$H$3,$H$3,$B$2:$B$10))))/SUM(IF($C$2:$C$10< LARGE($C$2:$C$10,$H$5),$B$2:$B$10*$C$2:$C$10/MAX($C$2:$C$10)))))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



This finds the top X rows by score, then assigns them the max amount. If there is a tie for 3rd place for example, both of them will get the max. Anyone else on the list will get marbles assigned proportionately based on their score, and on how many marbles are actually available.

I don't actually use the minimum marbles per person value, since the way this calculates, no one should get 0, unless their score is 0. But it wouldn't be hard to add to the formula, depending on what other tweaks are needed. I could also add ROUND to the formula to make it just 1 decimal.

Also, there is the possibility of some marbles not being assigned. Change the H5 value to 2 for example. This happens because at least 1 person not in the top X hit the max marbles per person condition. If you want to try to assign all the excess marbles to the other people, it would probably take some kind of iterative process. That's definitely a VBA thing, maybe Solver. And I don't know what the marbles represent, or how people decide on how many to request, but it would be easy for someone to get the max marbles just by requesting a large number (and it would throw off the calculations for everyone else).

I created the score ratio based on the person's score divided by the maximum score in column C, or 110. If the maximum score is 100, and that's extra credit or something, and you want the ratios based on 100, replace the MAX($C$2:$C$10) in the formula (2 places) with 100.


In any case, take a look and see if it works for you.
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,669
Members
448,977
Latest member
moonlight6

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