+ Reply to Thread
Results 1 to 6 of 6

Thread: Find a number combination in a group of cells

  1. #1
    Registered User
    Join Date
    08-29-2011
    Location
    Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    5

    Find a number combination in a group of cells

    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.

  2. #2
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,285

    Re: Find a number combination in a group of cells

    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.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * below to say thanks.

  3. #3
    Valued Forum Contributor
    Join Date
    03-13-2004
    Location
    Gothenburg/Stockholm, Sweden
    MS-Off Ver
    Excel 2003 and reluctantly Excel 2007
    Posts
    630

    Re: Find a number combination in a group of cells

    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

  4. #4
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,285

    Re: Find a number combination in a group of cells

    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.

  5. #5
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,786

    Re: Find a number combination in a group of cells

    you could just use solver
    Attached Files Attached Files
    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

  6. #6
    Valued Forum Contributor
    Join Date
    03-13-2004
    Location
    Gothenburg/Stockholm, Sweden
    MS-Off Ver
    Excel 2003 and reluctantly Excel 2007
    Posts
    630

    Re: Find a number combination in a group of cells

    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0