It's a little more involved, but when using Solver, the general idea is to
add the solution back into the constraints. When finding a specific Sum,
and your Binary data (1's) are in, for example, B1,B3, & B5, you add the
constraint that B1+B3+B5<=2. Due to Precision, Tolerance...etc when using
Solver, I will make it <=2.5. Then resolve.
What this is doing is that if one solution used these 3 cells, then any
other solution can not use these same 3 cells. Again, it's a little more
involved, but that's the general idea. It works pretty well, but you have
to set up Solver correctly.
...
For an array of 20 values, there are 2^20 - 1 = 1,048,575 nonempty subsets.
Granted it may be possible to use heuristics to eliminate many of these, but
there would still be possibly several thousand subsets to sum. These values may
be summed quickly, but adding constraints to Solver would add considerably to
the total processing time. Also, if there were a few dozen combinations that sum
to the target value, at what point would Solver no longer be able to accomodate
additional constraints? Then back to my previous comment about using Solver when
there are both positive and negative values, you couldn't apply this sort of
constraint. If the set of values were {1,2,3,4,5,6,-1,-3,-5,-7} and the target
value were 10, then 2+3+5 would be a solution, but so would 1+2+3+5-1,
1+2+3+5+6-7, and several others.
If all values were positive, then your proposed constraints would work (subject
to Solver's limitation on the number of constraints it can accept). But if there
were positive and negative values then your proposed constraints would eliminate
possible solutions.