View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Tom Hutchins Tom Hutchins is offline
external usenet poster
 
Posts: 1,069
Default Finding amounts that sum to a number

Try these instructions for Solver, from a reply by B. R. Ramachandran to a
similar question:

Supposing the set of numbers is in A2:A11. Enter 1 in each cell in B2 to
B11. Place the single number in C2. Enter the following formula in some
other cell (say C3)
=SUMPRODUCT(A2:A11,B2:B11)-C2 and click ENTER.

Now you are going to use the Solver (the "Solver" add-in should be installed
for this) to find the combination of numbers in Column A whose total would be
equal to the single number you have entered in C2. For that,
"Tools" -- "Solver" -- in "Solver Parameters" window,

"Set Target Cell" $C$3
"Equal To" "Value of" 0
"By Changing Cells" $B$2:$B$11
"Subject to the Constraints"-- click "Add" -- enter $B2$2:$B$11, select
"bin" from the popdown list (This would add a constraint which would read as
"$B$2:$B$11=binary")
Click "Solve"
The solver would find the solution by changing some of the 1's in Column B
to 0's. The set of Column A numbers for which Column B is 1 (and not 0) is
the solution for your problem. If the solution is satisfactory, click "Keep
Solver Solution". Note that if more than one solution is possible, Solver
would find the first solution.

To add a nice touch, maybe you can use Conditional Formatting to highlight
the numbers in Column A for which Column B is 1.

This only finds a single solution. I (Hutch) have a lengthy recursive macro
that can find multiple solutions (if they exist). If the Solver approach
doesn't satisfy, let me know and I can post my code for you.

Hope this helps,

Hutch

"Nikki0195" wrote:

I have a LARGE spreadsheet of items that I am trying to reconcile for an
entire month range. The issue that I am having - the bank statement may show
one amount ($1,000), where the spreadsheet may have 4 random amounts that
equal $1,000. I need to be able to find the items that equal a specified
number without having to manually add up several amounts and hope for a
match. Any suggestions? I have tried Conditional Formatting, Conditional
Sum, and the Solver add-in. None of these will give me what I need -
considering that I have about 400 items in a month.

Thank you all so much for taking the time to read this!