Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Find numbers in an array that sum to a certain number

How do I get Excel to search an array of numbers and find only those numbers
that sum to a certain total? Which of the following numbers (3,5,7,14,20)
total 22? Answer: 3, 5, and 14 total 22
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default Find numbers in an array that sum to a certain number

tommydancer wrote...
How do I get Excel to search an array of numbers and find only those numbers
that sum to a certain total? Which of the following numbers (3,5,7,14,20)
total 22? Answer: 3, 5, and 14 total 22


This is a classic programming problem. The answer is that there's no
guaranteed way to find the solution to this problem that doesn't
require iterating through all possible subsets of the individual
numbers. And if there are N individual numbers, there are 2^N-1
nontrivial subsets. For N-5, that means only checking 31 subsets of the
numbers. For N=20, there's over a million. For N=100, you'd need months
of uninterrupted supercomputer time.

Actually, that overstates the problem a bit, but only a bit. Heuristics
can be applied to limit the subsets, but that only eliminates a few
orders of magnitude.

Use Google Groups advanced search to find previous responses to this
sort of question. You could use the search words SUMPRODUCT and SOLVER
as well as the search phrase "sum to" to find solutions that'd give one
possible combination. If you want all such combinations, you'll need to
use VBA, and it could take a LONG time, long as in hours. Solutions
that'd require days or longer would exceed system resources long before
that.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 47
Default Find numbers in an array that sum to a certain number

Assuming your data on column A
A1=3
A2=5
A3=7
A4=14
A5=20
On column B
B1=1
B2=1
B3=1
B4=1
B5=1
On column C
A1*B1
A2*B2 so on....

enter formula on cell C6 =SUM(C1:C5)
Tool | Solver | Set Target Cell: $C$6
Equal To: Select Value of: 22
By Changing Cells: $B$1:$B$5 click Add
Change Constraint Cell Reference: $B$1:$B$5 also change <= to int then click
Add
Click Solve, Keep Sover Solution, click OK


"tommydancer" wrote:

How do I get Excel to search an array of numbers and find only those numbers
that sum to a certain total? Which of the following numbers (3,5,7,14,20)
total 22? Answer: 3, 5, and 14 total 22

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,071
Default Find numbers in an array that sum to a certain number

In article ,
says...
How do I get Excel to search an array of numbers and find only those numbers
that sum to a certain total? Which of the following numbers (3,5,7,14,20)
total 22? Answer: 3, 5, and 14 total 22

For a template, see
Find a set of amounts that match a target value
http://www.tushar-mehta.com/excel/ti...set-match.html

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find sum in list of of numbers Jim Thomlinson Excel Discussion (Misc queries) 5 January 4th 06 07:07 PM
find sum in list of of numbers Jim Thomlinson New Users to Excel 5 January 4th 06 07:07 PM
find closest match to a reference number in a row of numbers Nick Krill Excel Discussion (Misc queries) 4 December 21st 05 11:59 AM
How do I find the last number in a column of numbers? Shyam Excel Worksheet Functions 2 August 26th 05 03:05 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 10:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"