I need to fill randomly a set of more than 20 rows and columns with numbers from 0 to 4. However, I need to set a limit to the sum of each line and each column. Lets say, each row has to sum up to a value equal or lower than 4 and each column to a value equal or lower than 6.
The remaining cells could be filled with zeros.
I don't know how to use VBA, macros, etc. I already tried with the Data Validation option but it only lets me set ONE restriction: either constrain the sum of each row or the sum of each column or to allow values from 0 to 4 only. But not the three of them which is what I need.
One example could be:
0 1 2 0 0 0 0 1
0 3 0 1 0 0 0 0
1 0 0 2 0 0 0 0
4 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0
Is there a formula/command to make this possible? If so, would it be possible to also set the distribution of the data (i.e Normal)?
Another way of doing this I have thought of is to fill the cells myself, instead of letting Excel do it randmonly. But either way I've got the same issue. I'd want Excel to only let me use values form 0 to 4, so that if I fill the cells of the row and it sums up to 4 or less it'd either stop me or let me fill other cells but changing/adjusting automatically the values of the former ones, so that it will always sums 4 or less. And same thing with the columns.
An example:
0 1 1 0 0 1 0 4 --> The sum is greater than 4, so the former values would be automatically so that the condition of summing up to 4 would be met. This way, the modified row could be etiher:
0 1 1 0 0 1 0 1, or , 0 1 1 0 0 1 0 0
THANKS A LOT!
Bookmarks