Rrandomly selecting a sum of three separate columns in VBA for a set of particular totals

elsrik

New Member
Joined
Jul 23, 2017
Messages
1
Hello,

I need to randomly pick individual and repeated entries from an array that has 3 separate integers via VB script, whose sum must equal separate particular values.




I've worked a bit with VBA in Excel before, but this is stumping me. :confused:

I have seen examples with how to use Solver for a single row, but have not figured out how to achieve this.


Example:


SOURCE DATA:


name Col A Col B Col C
-----------------------------------
Red 2 3 4
Yellow 2 4 5
Blue 3 1 2
Green 1 1 1
Purple 1 4 1
Orange 0 2 5
Black 4 4 4
White 1 1 1
Brown 3 3 3
Pink 0 1 0
Blaze Orange 0 0 0
Ultraviolet 1 0 0
Crystal 5 1 0




OUTPUT:


Col A Col B Col C
Target Value 10 12 8
-----------------------------------
Green 1 1 1
Purple 1 4 1
Purple 1 4 1
Crystal 5 1 0
Orange 0 2 5
Ultraviolet 1 0 0
Ultraviolet 1 0 0


I'd guess that the results should be random each time, if it's a random search for the answer.

Any tips or assistance would be appreciated.


Thanks,

elsrik
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,224,862
Messages
6,181,461
Members
453,043
Latest member
Sronquest

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