+ Reply to Thread
Results 1 to 2 of 2

backwards sum

  1. #1
    choice
    Guest

    backwards sum

    i have a list of numbers in column A, and a value in B1.
    is there a way to find if/what numbers in column A can add up to the value
    in B1?

    example Column A: 3,67,235,843,784,23,457647,1,4,235
    B1: 305 (which would be 3+67+235)

    hope that makes sense.
    thanks in advance

  2. #2
    Forum Contributor
    Join Date
    02-15-2005
    Location
    Blackpool, UK
    Posts
    137
    Well - yes it's possible, but I can only think that you'd have to check every possible combination. In your 10 cell example this is 1023 checks.

    OK, you can trim this down by removing value already greater than the value you are after.

    But a macro would need to be written to perform the check and the performance would be very slow if you had very many more cells to check. 20 cells, for example, is a potential 1,048,575 checks!

    To code a macro to do this I would:

    - Build an array of values < target value
    - If any cell value = target value then stop displaying true message + combination
    - Check every possible combination resulting array
    - If combination = target value then stop displaying true message + combination
    - Else if all combinations checked, stop displaying false message

    HTH

    Art

+ 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