Check summation of all possible combinations equals certain given value

Prativa

New Member
Joined
Jul 11, 2022
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello Team,

I am having a requirement where I need to check the summation of all possible combinations of column Quantity is equals SL_Quantity OR NOT.
How do I know the summation of which all rows value of Quantity column is equals SL_Quantity using conditional formatting.

Let say C5+c8+c11+c2=E2.
Then in this case how do I know which all rows of column "Quantity" I have to add to make the value equal to "SL_Quantity" , also I will have to highlight those rows( C5,c8,c11,c2) with green color.
1663738813728.png
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
This is called the Subset Sum Problem. There can be more than one solution. And the algorithms for this are not going to be instant like Excel's functions. (This is not a trivial calculation.) The more numbers you have in Column C, the longer you will have to wait for a result. If you have a lot of numbers, be prepared to wait a while!

What do you want to happen if there is more than 1 combination of the numbers in Column C whose sum is the number in E2?

If anyone is interested in answering this question, I have seen several people reference this page: Combination of numbers that sum or match a target value. But in this Reddit post, you will find a link to a .xlsm Workbook with supposedly a faster algorithm. Specifically, in the 3rd comment in that thread, the commenter said:
The code I linked to took 2 minutes 27 seconds to find all the combinations. I thought that was fast. Your code took 11 seconds
, where the 2 minute 27 performer was the code from the first link I provided above.
 
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,887
Members
449,057
Latest member
Moo4247

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