How to distribute a set of numbers proportionally across cells in a TABLE

Phantom1

New Member
Joined
Sep 26, 2018
Messages
24
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello friends.

I have a distribution problem that i encounter all the time and need to speed up the process with formulas or vba. Any help is highly appreciated.

Lets say that we have 19 companies (A,B ,... S) that each one supply us with a number of a specific item. (All items are the same and the numbers given may vary)
After we code the items (so only us know from which company each item was received), we need to mix the items and return to the companies same number they gave us, for testing.

My problem is how to distribute automatically the items (integers) near to their ratios so can add up to their total not only in rows but in columns also
I use the round function and then correct the numbers manually , but that requires a lot of effort and time.

I have already read a similar question in the forum but the answer does not work in my case. "How to distribute a set number proportionally across cells and still keeping the total at set number" by Delta21

Some things to keep in mind of secondary importance are.
1. No company gets back for testing more than 10% of its own items
2. The maximum number of items someone gets back for testing from a company, appears at least twice so he cannot trace back the written code on an item to its original location.

I give a sample image of a finished problem.

Thanks in advance
 

Attachments

  • table.PNG
    table.PNG
    35.9 KB · Views: 117
Thanks Dermot.
Some improvements necessary if you please.
We cannot have negative numbers in distribution

1642449626276.png


and distribute at least two same numbers of the max value in column. For example company B can assume the code been used for company A pretty easy. We could make them not be sure about that if we decrease the number of items from A and increase number of items from C for example , so the two numbers would be pretty close.
1642450070046.png

Thanks again for a very good solution. Very close for what i am looking for.
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
that "randarray" is filling an array of x (here som) elements with a random value between 0 and 1.
In 2016, you need a few steps more
VBA Code:
2021
  rand = Application.Transpose(WorksheetFunction.RandArray(som))
2016
ReDim rand(1 To som)
     Randomize
     For i = 1 To UBound(rand): rand(i) = Rnd: Next
And the stupid error was to forget substracting 1, and so in supplier 26, suddenly there was also 1 item.
r1 = Application.Match(r - 1, a3, 1)

But i suppose Dermot's solution is better.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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