Hi guys, I'm having problems building an routine to solve this thing:
I need to run combinations of the 5 values below (a,b,c,d,e) and check if the sum of the combinations matches with one of the 3 results (v1,v2,v3).
a: 1,21
b: 1,08
c: 2,24
d: 0,17
e: 308,01
v1: 1,25
v2: 308,01
v3: 3,45
If positive, the combined values would be associated with the result value, like:
b+d = 1,25
so b = v1 and d = v1
a+c = 3,45
so a = v3 and c = v3
e = 308,01
so e = v2
In the end, It would build an array like this
a: v3
b: v1
c: v3
d: v1
e: v2
As you can see, it doesn't matter the order of the values, since I'll sum them all together. Also, the results could be the sum of every value, as it could be a single value.
The example I used is real, and it is a short one, with only 5 values, there are cases with over 30 values, and more then 3000 cases, so, doing it manually is not an option.
The real problem is with the combination routine, the rest of it is not a problem.
------------ EDIT ------------
By the way, right now, I'm trying to make it work like a binary progression:
Array1[a,b,c,d,e]
Array2[0,0,0,0,0] (boolean)
Array2 would grow as a binary progression:
[0,0,0,0,1]
[0,0,0,1,0]
[0,0,0,1,1]
...
And each time, it would create a third array:
Array3 = Array2*Array1
so:
Select Case WorksheetFuntion.Sum(Array3)Case v1
...
Case v2
...
Case v3
...
End Select
Just figuring out how to make it happen...
------------ EDIT ------------
Thanks in advance for your attention.
Bookmarks