Finding the elements of the sum

  • Thread starter Thread starter =?iso-8859-1?Q?J=FCri_Kuusik?=
  • Start date Start date
?

=?iso-8859-1?Q?J=FCri_Kuusik?=

Hello!
Can you please help me in solving following problem:

Given is the amount (for example 56,67)
and massive: (for example 45,6; -3,2; 11,07; 58)

Exercise is to show the components of the sum, which
perform given amount.

In our example the answer is

1. - 45,6
3. - 11,07

Can You give me an algorithm (and VBA code) to solve this
problem in
general - Given is N numbers (negative and positive) and
searched amount (negative or positive)?

If You have questions about problem, please ask from me:
(e-mail address removed)

Regards,
Jüri.
 
Solver could do this. Put the possible components in, say,
column A, enter 0's in column B, column C = A*B. In next
row of C, sum rows above it. This would be cell C5 in your
example. Run solver making column B the adjustable cells,
constrained to integers, >= 0 and <=1. Target C5 equal to the
desired sum.

HTH,
Merjet
 
Back
Top