Using Excel Formula instead of Solver addins

ExcelNewbie2020

Active Member
Joined
Dec 3, 2020
Messages
293
Office Version
  1. 365
Platform
  1. Windows
having multiple projects with limited budget. Using excel formula, need to maximize the number of quantity without exceeding the set budget cost.. This scenario could be solved by the solver, but the solver needs to recalculate everytime the data change.


Excel_Free_Workbook_Solver_Basics_XelPlus.xlsx
ABCDEFGHIJ
1RAW DATAEXPECTED RESULT
2Project nameTotal CostsQtyProject nameTotal CostsQty
3Project A640035Project A640035
4Project B790020Project D650040
5Project C600013Project F320030
6Project D650040Project G870032
7Project E340025Project I900036
8Project F320030Project E340025
9Project G87003237200198
10Project H960015
11Project I900036
1260700
13
14Constraints:
15budget cost40000
16
17
18
19
Sheet1
Cell Formulas
RangeFormula
I9:J9I9=SUM(I3:I8)
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try this? It won't work beyond a certain number of projects...

Book1
ABCDEFGHIJ
1RAW DATAEXPECTED RESULT
2Project nameTotal CostsQtyProject nameTotal CostsQty
3Project A640035Project A640035
4Project B790020Project D650040
5Project C600013Project E340025
6Project D650040Project F320030
7Project E340025Project G870032
8Project F320030Project I900036
9Project G87003237200198
10Project H960015
11Project I900036
1260700
13
14Constraints:
15budget cost40000
Sheet2
Cell Formulas
RangeFormula
H3:J8H3=LET( rng,A3:C11, con,B15, _a,INDEX(rng,,2), _b,--MID(BASE(SEQUENCE(2^COUNTA(_a)-1),2,COUNTA(_a)),SEQUENCE(,COUNTA(_a)),1), _c,MMULT(_b,_a), _d,MMULT(_b,INDEX(rng,,3)), FILTER(rng,TRANSPOSE(FILTER(_b,(_d=MAX(FILTER(_d,_c<=con)))*(_c<=con)))))
I9:J9I9=SUM(I3:I8)
Dynamic array formulas.
 
Last edited:
Upvote 0
Try this? It won't work beyond a certain number of projects...

Book1
ABCDEFGHIJ
1RAW DATAEXPECTED RESULT
2Project nameTotal CostsQtyProject nameTotal CostsQty
3Project A640035Project A640035
4Project B790020Project D650040
5Project C600013Project E340025
6Project D650040Project F320030
7Project E340025Project G870032
8Project F320030Project I900036
9Project G87003237200198
10Project H960015
11Project I900036
1260700
13
14Constraints:
15budget cost40000
Sheet2
Cell Formulas
RangeFormula
H3:J8H3=LET( rng,A3:C11, con,B15, _a,INDEX(rng,,2), _b,--MID(BASE(SEQUENCE(2^COUNTA(_a)-1),2,COUNTA(_a)),SEQUENCE(,COUNTA(_a)),1), _c,MMULT(_b,_a), _d,MMULT(_b,INDEX(rng,,3)), FILTER(rng,TRANSPOSE(FILTER(_b,(_d=MAX(FILTER(_d,_c<=con)))*(_c<=con)))))
I9:J9I9=SUM(I3:I8)
Dynamic array formulas.
it workx man.. thank you so much
 
Upvote 0
Try this? It won't work beyond a certain number of projects...

Book1
ABCDEFGHIJ
1RAW DATAEXPECTED RESULT
2Project nameTotal CostsQtyProject nameTotal CostsQty
3Project A640035Project A640035
4Project B790020Project D650040
5Project C600013Project E340025
6Project D650040Project F320030
7Project E340025Project G870032
8Project F320030Project I900036
9Project G87003237200198
10Project H960015
11Project I900036
1260700
13
14Constraints:
15budget cost40000
Sheet2
Cell Formulas
RangeFormula
H3:J8H3=LET( rng,A3:C11, con,B15, _a,INDEX(rng,,2), _b,--MID(BASE(SEQUENCE(2^COUNTA(_a)-1),2,COUNTA(_a)),SEQUENCE(,COUNTA(_a)),1), _c,MMULT(_b,_a), _d,MMULT(_b,INDEX(rng,,3)), FILTER(rng,TRANSPOSE(FILTER(_b,(_d=MAX(FILTER(_d,_c<=con)))*(_c<=con)))))
I9:J9I9=SUM(I3:I8)
Dynamic array formulas.
sir, the formula initially works, but when i run and play it with my actual file it sometimes returns to error. I noticed the error occur if there is a tie qty near the bottom cost..

Excel_Free_Workbook_Solver_Basics_XelPlus.xlsx
ABCDEFGHIJK
1RAW DATAEXPECTED RESULT (NEW)
2Project nameTotal CostsQtyProject nameTotal CostsQty
3Project D800046Project D800046
4Project C960045Project I700043
5Project I700043Project B600042
6Project A600042Project G500040
7Project B600042Project H450039
8Project G500040Project F450039
9Project H450039Project E450039
10Project F45003939500288
11Project E450039
12
13
14
15budget cost40000
16
17
18
19
20#VALUE!
21
22
23
24
25
26
Sheet1
Cell Formulas
RangeFormula
I10:J10I10=SUM(I3:I9)
H20H20=LET( rng,A3:C11, con,B15, _a,INDEX(rng,,2), _b,--MID(BASE(SEQUENCE(2^COUNTA(_a)-1),2,COUNTA(_a)),SEQUENCE(,COUNTA(_a)),1), _c,MMULT(_b,_a), _d,MMULT(_b,INDEX(rng,,3)), FILTER(rng,TRANSPOSE(FILTER(_b,(_d=MAX(FILTER(_d,_c<=con)))*(_c<=con)))))
 
Upvote 0
It's because there's a draw in the max quantity within your budget. What do you want to happen when there is a draw?
 
Upvote 0
thank you, just like on the expected result. if there is a draw, check for the project cost then optimize the remaining cost
 
Upvote 0
The cost and quantity in your example is the same though; so it should just pick either one?
D-I-B/A-G-H-F-E
 
Upvote 0
Anyway try:
Excel Formula:
=LET(
rng,A3:C11,
con,B15,
_a,INDEX(rng,,2),
_b,--MID(BASE(SEQUENCE(2^COUNTA(_a)-1),2,COUNTA(_a)),SEQUENCE(,COUNTA(_a)),1),
_c,MMULT(_b,_a),
_d,SORTBY(MMULT(_b,INDEX(rng,,3)),_c),
FILTER(rng,TRANSPOSE(INDEX(FILTER(SORTBY(_b,_c),(_d=MAX(FILTER(_d,SORT(_c)<=con)))*(SORT(_c)<=con)),1,))))
 
Upvote 0
Solution

Forum statistics

Threads
1,215,208
Messages
6,123,642
Members
449,111
Latest member
ghennedy

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