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?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
8,052
Office Version
  1. 365
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)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,502
Messages
5,832,095
Members
430,110
Latest member
Chyke_mxl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top