find the best match with sizing based on a certain sum VBA

Sotos13

New Member
Joined
Mar 8, 2019
Messages
42
Hello everyone,

i have this problem i have to solve. It's not that easy but here it is .... In column A i have a list of sizes maybe Hundreds Thousands.. and they might be from 10 to 100 in column B. i also have a certain target range for example 95 to 100.
i want to add all numbers in column B in order to result from 90 to 100(my target range) for example A1 with A10 = 100, A2+A3+ A11 =90, A4+A6 =90, then A5+A12 = 95 and so on.. The numbers which are used cannot be used again. The result will be a table with this info as the table below SIZE 1 and SIZE 10 100 etc or A1 and A10 something like that. I know it's hard but if anyone has an idea please be free to share

[TABLE="width: 695"]
<tbody>[TR]
[TD]SIZE 1[/TD]
[TD="align: right"] 90[/TD]
[TD] A1+A10[/TD]
[TD="align: right"] 100[/TD]
[TD] Range 90- 100[/TD]
[TD][/TD]
[TD="colspan: 2"]RESULTS[/TD]
[/TR]
[TR]
[TD]SIZE 2[/TD]
[TD="align: right"] 50[/TD]
[TD] A2+A3+A11[/TD]
[TD="align: right"]90[/TD]
[TD][/TD]
[TD][/TD]
[TD]SIZE 1 and SIZE 10[/TD]
[TD="align: right"]100[/TD]
[/TR]
[TR]
[TD]SIZE 3[/TD]
[TD="align: right"]30[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]SIZE 2 and SIZE 3 and SIZE 11[/TD]
[TD="align: right"]90[/TD]
[/TR]
[TR]
[TD]SIZE 4[/TD]
[TD="align: right"]60[/TD]
[TD] A4+A6[/TD]
[TD="align: right"]90[/TD]
[TD][/TD]
[TD][/TD]
[TD]SIZE 4 and SIZE 6[/TD]
[TD="align: right"]90[/TD]
[/TR]
[TR]
[TD]SIZE 5[/TD]
[TD="align: right"]70[/TD]
[TD] A5+A12[/TD]
[TD="align: right"]95[/TD]
[TD][/TD]
[TD][/TD]
[TD]SIZE 5 and SIZE 12[/TD]
[TD="align: right"]95[/TD]
[/TR]
[TR]
[TD]SIZE 6[/TD]
[TD="align: right"]30[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]SIZE 7 and SIZE 16[/TD]
[TD="align: right"]100[/TD]
[/TR]
[TR]
[TD]SIZE 7[/TD]
[TD="align: right"]80[/TD]
[TD] A7+A16[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SIZE 8[/TD]
[TD="align: right"]40[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SIZE 9[/TD]
[TD="align: right"]80[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SIZE 10[/TD]
[TD="align: right"]10[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SIZE 11[/TD]
[TD="align: right"]10[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SIZE 12[/TD]
[TD="align: right"]25[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SIZE 13[/TD]
[TD="align: right"]35[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SIZE 14[/TD]
[TD="align: right"]75[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SIZE 15[/TD]
[TD="align: right"]95[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]SIZE 16[/TD]
[TD="align: right"]20[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 695"]
<tbody>[TR]
[TD]Thanks[/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
great Dante....amazing !!!
thank you very much...i might come back to you with some questions concerning the code just so i can make some things more clear to me.
if you could reply ..but thanks again

Regards
Sotos13
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
great Dante....amazing !!!
thank you very much...i might come back to you with some questions concerning the code just so i can make some things more clear to me.
if you could reply ..but thanks again

Regards
Sotos13

Of course, tell me what doubts you have?
 
Upvote 0

Forum statistics

Threads
1,224,750
Messages
6,180,740
Members
452,996
Latest member
nelsonsix66

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