Hi All, I would like to ask your help with VBA.
As I've to calculate all the possible combinations, without repetitions, between 11 decimal numbers entries based on respectively 1,2,3,4,5,6,7,8,9,10,11 elements-combination based. For example, one 1 element based element combination is 5.47; one 2 based elements combination is 12.85 (3.53+9.32); one 6 based elements combination is 125.32 (3.53+94.61+9.32+6.88+5.51+5.47), and so on.
As possible solution I found the following VBA algorithm, but honestly I don't know how to run it. Somebody could help me in this?
// VBA
Function Factorial(n As Integer) As Floating
Factorial = 1
For i = 1 To n
Factorial = Factorial * i
Next
End Function
Function NbCombinations (k As Integer, n As Integer) As Floating
Dim z As Integer
z = n - k
NbCombinations = Factorial / (Factorial(k) * Factorial(z))
End Function
As I've to calculate all the possible combinations, without repetitions, between 11 decimal numbers entries based on respectively 1,2,3,4,5,6,7,8,9,10,11 elements-combination based. For example, one 1 element based element combination is 5.47; one 2 based elements combination is 12.85 (3.53+9.32); one 6 based elements combination is 125.32 (3.53+94.61+9.32+6.88+5.51+5.47), and so on.
As possible solution I found the following VBA algorithm, but honestly I don't know how to run it. Somebody could help me in this?
// VBA
Function Factorial(n As Integer) As Floating
Factorial = 1
For i = 1 To n
Factorial = Factorial * i
Next
End Function
Function NbCombinations (k As Integer, n As Integer) As Floating
Dim z As Integer
z = n - k
NbCombinations = Factorial / (Factorial(k) * Factorial(z))
End Function