Hello everybody. I need some help to write an udf in excel VBA that could pull a number from each of several columns (with elements in common) so that all pulled numbers are different. Let's say that the starting columns were A:[1,3,6], B:[2,4,5,6], C:[2,3,7], D:[1]. One possible solution could be [3,4,7,1]. The function has to consider dependancies between columns, in fact, in this case the number 1 can't be pulled from column A or else it won't be possible to pull anything from column D.
to work around the problem i'm using a formula that calculates all possible combinations between columns and then filters for distinct values only. Then, i take a random solution using ARRAY and RANDBETWEEN formulas. this process, however, contains two big flaws:
1-Once the number of combinations exceeds the row limit number (1048576), the formula returns an error.
2-The formula calculates all possible solutions so it becomes increasingly slower as i add new columns.
I'm looking for an udf using excel VBA that gets rid of these problems.
In this worksheet i provide some examples to better understand the problem
EXAMPLES.xlsm
i already posted this question on reddit, but no one answered me yet. i would link the thread but the website is not letting me
Bookmarks