+ Reply to Thread
Results 1 to 7 of 7

Which entries add up to x?

  1. #1
    Registered User
    Join Date
    11-03-2009
    Location
    Travelers Rest, SC
    MS-Off Ver
    Excel 2003
    Posts
    1

    Which entries add up to x?

    I am trying to find a way to do the following:

    I have a list of x numbers (lets say 100 numbers)
    I know that 2 of the numbers in the list add up to y (lets say 255.21)

    Is there a way in Excel to find which two specific values add up to that value? (In the hypothetical above, it may find 2 values that are 130 and 125.21)

    Finally (and only if the above can be accomplished), how would the procedure change if you had to combine 3, 4, or z numbers to reach the specific value?

    Many thanks for any tips you can offer!!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Which entries add up to x?

    This code is by Tushar Mehta. You need to read the comments for instructions.
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    09-13-2008
    Location
    Los Angeles, CA
    MS-Off Ver
    365
    Posts
    120

    Re: Which entries add up to x?

    This is GREAT, except it doesn't seem to work with negative numbers... any idea how to change that?

    For example, the following does not work:

    10
    11
    12
    -1
    13
    14

    if you're looking for 9, it won't come up with any. if you're looking for 10, it would only come up with 1 combo, when there are 2.

    Any help will be greatly appreciated!

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Which entries add up to x?

    ... it doesn't seem to work with negative numbers
    Indeed it doesn't -- the algorithm assumes that all numbers are positive to cut off when some selection exceeds the total.

  5. #5
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Which entries add up to x?

    Quote Originally Posted by koticphreak View Post
    This is GREAT, except it doesn't seem to work with negative numbers... any idea how to change that?

    For example, the following does not work:

    10
    11
    12
    -1
    13
    14

    if you're looking for 9, it won't come up with any. if you're looking for 10, it would only come up with 1 combo, when there are 2.

    Any help will be greatly appreciated!
    Google for SOLVER

  6. #6
    Forum Contributor
    Join Date
    09-13-2008
    Location
    Los Angeles, CA
    MS-Off Ver
    365
    Posts
    120

    Re: Which entries add up to x?

    any easy way to mod it to also include negative numbers?

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Which entries add up to x?

    Can the numbers be sorted from smallest to largest?

    What's the largest number of numbers?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1