View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Peo Sjoblom Peo Sjoblom is offline
external usenet poster
 
Posts: 3,268
Default calculate various cells to acheive a specific value

You would need to use code or the solver add-in, for the solver add-in using
your example you would create something like this



546 1
9732 1
654 1
6548 1
687 1
9871 1


assume that is A1:B6 (you would put 1s in B1:B6)

in C1 put

=SUMPRODUCT(A1:A6,B1:B6)


in D1 put

10,525

do toolssolver


then set target cell $C$1 equal to value of 10525
by changing cells $B$1:$B$6

then click add and use $B$1:$B$6 and from dropdown select bin, click OK

then click solve



depending on how large (note that the solver that comes with Excel is
limited)
the range is it can take some time to get a solution, but your example gives
this result

546 0
9732 0
654 1
6548 0
687 0
9871 1


where the 1s in B1:B6 show which 2 amounts total 10,525


I believe Harlan Grove wrote VBA code to do this as well, you can Google on
that


--
Regards,

Peo Sjoblom








"Jennifer_C" <u35395@uwe wrote in message news:7455401029a02@uwe...
Hello,
I am trying to identify two cells within a column that total a specific
amount. For example:

ColA
546
9732
654
6548
687
9871

I need to find the two (or more cells in some cases) that would create the
total of 10,525.

For my current task, I have over 100 rows of data and I know two cells
equal
a specific amount, but I do not know which two. Any help, or assistance
given
would be greatly appreciated!

Jennifer