Looking for a specific sum within a range of numbers...

jgreen1025

New Member
Joined
May 16, 2003
Messages
9
Is there a way to find out if certain cells within a range sum up to a specific number? I often find myself looking for a certain amount - like I've got an error for a specific dollar amount - but I have a range of entries, and any combination of those numbers could sum up to the total of the error. I've tried selecting various cells with the hopes that I can randomly pick the right ones, but that's just hit or miss, and depending on how many cells (amounts) are involved, it could be impossible. Is there a formula or add-in that can check a range of numbers to see if any combination will sum up to a specific amount? (I'm using Excel 2000) Thanks!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Here' s an example from Tom Oglivy, Microsoft MVP, which uses Excel's Solver function.

In A1:A5 put
  • 14.56
    19.51
    105.64
    100.91
    21.60
The objective is to find which of the above numbers total to 221.11.

1. In B1:B5 put the number 1.
2. In B7 put: =SUMPRODUCT(A1:A5,B1:B5)
(you should get 262.22)

3. Go to Tools menu | Solver.
4. In "Set Target Cell", enter $B$7.
5. "In Equal to", click the "Value of" radio button and enter 221.11.
6. In the "by Changing Cells" box use the mouse to select B1:B5.
7. In "Subject to the Constants" area, click the Add button and then enter:

B1: B5 = Bin

8. Click OK.

Cells B1, B3, B4 should have a 1 in them, cells B2 and B5 will show zero, cell B7 will show 221.11.

After clicking "OK" (step 8 above) the Solver Results dialog box will appear - click OK to keep the results.

Enhancement:
Use Conditional Formatting to highlight the numbers in column A that sum to the target value.

1. Select A1.
2. Go to the Format menu | Conditional Formatting.
3. In the "Formula is" box enter "=B1=1" (no quotes)
4. Click the Format button and choose your formatting options.
5. Click OK, OK.
6. Use the Paintbrush to copy the formatting to the rest of the range.

There is a macro solution if you prefer.

HTH

Mike
 
Upvote 0
sorry to rake out this old excellent answer,

my problem is that within 116 lines of data my target value is not possible.

Is it possible to ask solver to find the 'nearest possible' solution - below but not more than a certain figure

thanks in advance

rich
 
Upvote 0
Mike - it's 15 years since you posted this solution, and it still works. It's brilliant, thank you so much :)
 
Upvote 0

Forum statistics

Threads
1,213,562
Messages
6,114,322
Members
448,564
Latest member
ED38

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
Back
Top