Re: find combination of cells that equals a sum
- From: SteveM <sbmack@xxxxxxxxxxxx>
- Date: Fri, 1 Feb 2008 15:47:11 -0800 (PST)
On Feb 1, 4:27 pm, Billy Rogers
<BillyRog...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Thanks for the help!
--
Billy Rogers
Dallas,TX
Currently Using SQL Server 2000, Office 2000 and Office 2003
http://thedataguru.blogspot.com/
"Gary''s Student" wrote:
Use Solver:
http://www.tushar-mehta.com/excel/templates/match_values/index.html#S...
--
Gary''s Student - gsnu200767
"Billy Rogers" wrote:
A friend asked me this
"Would there by chance be a function in Excel where you can choose a range
of cells with an amount in each cell and see if any combination of those
cells added up to a certain dollar amount? Say, I have a range of data that
adds up to $1,536,211.26, but I'm trying to see if any of the cells in that
range add up to $12,455.98."
Have any of you guys ever done something like this? I think it may have to
be solved using VBA.
thanks
--
Billy Rogers
Dallas,TX
Currently Using SQL Server 2000, Office 2000 and Office 2003
http://thedataguru.blogspot.com/
Solver's the best solution but the formulation on the link is the most
basic. It will report an infeasible solution if no combination of
values provides an exact equality. Better to Minimize the sum of the
deviations from the Target Value and if the solution is exact great,
if not, it tells you the best solution that gets you the closest.
The simplest extension is
Sum Xi - Target Value
But since you want to include both the negative and positive deviation
you can also run
Tanget Value - Sum Xi
And select the smallest difference.
Or really do it right, define an axillary variable Y and break into
its positive and negative components i.e.,
So Sum Xi + Y = Target Value
Y = Y' - Y'' so
Sum Xi + Y' - Y'' = Target Value
Then minimize on the auxillary variables with the single contraint
being an equality that is set to the target value and formulate this
way:
Min Y' + Y''
subject to
Sum Xi - Y' - Y'' = Target Value
SteveM
.
- Follow-Ups:
- Re: find combination of cells that equals a sum
- From: SteveM
- Re: find combination of cells that equals a sum
- References:
- find combination of cells that equals a sum
- From: Billy Rogers
- RE: find combination of cells that equals a sum
- From: Billy Rogers
- find combination of cells that equals a sum
- Prev by Date: Worksheets("Sheetname").Select refuses to kick in from User Defined function
- Next by Date: Re: Paste a function using a Macro
- Previous by thread: RE: find combination of cells that equals a sum
- Next by thread: Re: find combination of cells that equals a sum
- Index(es):
Relevant Pages
|