Excel VBA Recursion

Category: excel for developers


Clutchtastic on Fri, 22 Dec 2017 13:48:55

How do I program this in Excal VBA?

I have a variable number of dice. Each dice has a variable number of sides. Once I select how many dice I have and how many sides each dice has, I would like a VBA code to output each combination to excel. The final result would be a list where each row is a possible outcome from the rolling of the dice.



Ashidacchi on Sat, 23 Dec 2017 00:28:05

Hi Clutchtastic,

I guess you are a student and it is a school assignment. Is this correct?

I suppose it's a matter of combinations and permutations. You need to specify the minimum and maximum value about both the number of dices and the number of faces on each dice. 


Clutchtastic on Sat, 23 Dec 2017 15:09:53

Not a student, a working professional trying to write some code for optimization. I am using dice in my question because it is easier to explain than what I am actually using it for. Same principle though.

Yes, I realize that it is a combination issue, but I do not know how to write the code for a user specifying the number of dice, then how many sides of each dice.

ryguy72 on Sat, 23 Dec 2017 15:33:02

This sounds like an academic exercise.  Check out these links.



Some people confuse combinations (order doesn't matter) with permutations (order matters).  Just in case you want to learn about permutations...


Asadulla Javed on Sat, 30 Dec 2017 10:48:38

Can you give some sample. Say you take 3 Dice and each has 4 side. How you need the output.