VBA to randomly select from list with criteria

derek_e2015

New Member
Joined
May 18, 2021
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
Hello,
I am trying to randomly select from a list (say 4 items in the list) and input the values into say 16 cells, But each item in the list can only be used a set number of times
Also thinking may have to do something where i have the full list of all item on the list, each item listed the number of times they need to appear then input them into the 16 cells and shuffle them but have not looked into that yet
Example:

Bob - needs to appear 5 time
Lisa - needs to appear 3 times
Steve - needs to appear 2 times
Sue - needs to apear 6 times

So the chart would look like this

bob - steve - bob - lisa
sue - lisa - sue - Bob
Steve - bob - bob - sue
Sue - Sue - lisa - sue

I can create a macro to randomly select from the list with a formula but can not figure out how to get the items in the list to only appear a set number of times.
any assistance on this would be greatly appreciated very new to VBA/Macros and I am unable to find any thing out there like this

Thank you
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Sorry forgot to mention my actual list has 13 values and needs to input into about 100 cells, so I am trying to create a macro so I can add a Form control button to run the macro when ever I need to Can get the random part and the button, which is pretty easy but just cannot figure out how to get the item in the list to only appear a set number of times

Thank you
 
Upvote 0

Forum statistics

Threads
1,214,542
Messages
6,120,116
Members
448,945
Latest member
Vmanchoppy

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