Add any combination of cells to get a specific sum

Jane01

New Member
Joined
Dec 6, 2005
Messages
1
I have 100s of cells containing various numeric amounts. There is a specified amount I need to find, which will be the sum of any number of values - could be 2 values, could be 12.

For example I have the following data:

10
20
30
40
50
60
70
80
90
100

Let's say my target value is 150. Obviously there are several ways I could add these numbers to get 150. I need a formula that will combine various values to get my target number.

For the life of me, I can't figure out how to do this.

Thoughts?
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
7,988
Welcome to the board.

Do you want ALL of the combinations? Or just ONE solution?

If you want one solution, and the number of values will not exceed 16, you could use solver (tools --> solver... requires the solver add-in).

Define your your target cell = SUMPRODUCT(A1:A16,B1:B16) = to 150 or whatever by changing cells B1:B16 subject to the constraing that B1:B16 are binary.

Assuming solver can find a solution, solver will place a 1 next to the included values.

(See solver's help after clicking on options for more descriptions)
 

Watch MrExcel Video

Forum statistics

Threads
1,118,910
Messages
5,574,994
Members
412,633
Latest member
simon_elvin
Top