I'm looking for another excel game changer (for the work I do anyway).
I have a dollar amount, and I want to know if any combination of dollar amounts in a particular range of cells will equal that dollar amount. Is this possible in Excel?
Example: I have 20 different dollar amounts in a column. I want to know what combination of those 20 different dollar amounts, if any, will equal $257.97. The dollar amount I'm looking for and the numbers in the range will change with each use. I'm hoping for a formula, but VBA will work too as I could just make a template and copy / paste the numbers in.
I've come to learn to never doubt excel, but I have to admit that I'm having doubts on this one.
Hi Opie,
I did a problem like this a few months ago. See if the attached helps. If not then supply a sample file that we can work with to solve. To attach a sample, click on Go Advanced and then the Paper Clip Icon above the advanced message area.
One test is worth a thousand opinions.
Click the * below to say thanks.
Question MarvinP, could you please explain why you use range "A2:A51" in your formula?
I would have thought "A2:A50". I also did a test with solver but your solution works much faster!
Alf
Hi Alf,
I guess I used A2 to A51 because that was how many numbers there were to pick from in the original problem. Feel free to change the ranges if more numbers are needed.
I think we, as humans, get stuck on needing a formula to calculate things. Computers never get tired of guessing so I like doing random picks of numbers to see if they add up. In this problem it was a little different as the OP didn't say how many numbers needed to be used to sum to the total. I'm not sure my code did it correctly but the idea was still valid.
One test is worth a thousand opinions.
Click the * below to say thanks.
you could just use solver
Last edited by martindwilson; 10-29-2011 at 09:10 PM.
"Unless otherwise stated all my comments are directed at OP"
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
Thans for explanation MarvinP. Reason I asked was that changing the range A2:A51 in your formula to A2:A50 and running the macro gives me a #REF! value and I can't understand why.
Alf
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks