Find which values in an array add up to a total

benjicat

New Member
Joined
Jul 13, 2010
Messages
22
I'd like to know if anyone has a function in Access VBA that accomplishes a similar goal to the challenge presented here:

http://www.mrexcel.com/pc09.shtml

Essentially I would like to have a function that will find which values in an array of values would add up to a set amount. So if I passed the function an array with {1, 2, 4, 6} and I wanted to know which of the values in that array added up to 10, the function would return and array with {4, 6}. The solution posted in the link above is intended for Excel and is based on a range of values, but I would like something similar in Access VBA that is based on an array rather than an Excel range. Is that possible?

-benjicat
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
You may want to consult
http://en.wikipedia.org/wiki/Bin_packing_problem
Also the Knapsack and Subset Sum solutions as well.

I haven't seen an access solution, so would be curious if one exists. It might be that access just doesn't have enough "horsepower" to accomplish this (maybe only smaller subsets). That is why you will see solutions for SQL Server, oracle and other programming languages.

HTH,
CT
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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