How to use Excel Solver with lookups?

phort

New Member
Joined
Dec 12, 2017
Messages
1
Is there a way to use the solver with the data shown below? I want to have the Solver Table (Columns F-I) pull the data (Columns A-D) with the following constraints. 1) Maximize the sum of the profit (Column H), 2) Keep the sum of the Lbs <= 300 (Column I), 3) Each type must include two different products

ABCDFGHI
1ProductTypeProfitLbsTypeProductProfitLbs
2CarrotsVegetable10020Fruit
3ApplesFruit8030Fruit
4BananasFruit6525Vegetable
5PorkMeat9050Vegetable
6SalmonFish7035Dairy
7TroutFish8025Dairy
8HalibutFish4530Meat
9OrangesFruit2535Meat
10BeansVegetable2520Fish
11BeefMeat8040Fish
12TomatoVegetable4045=sum(H2:H11)=sum(I2:I11)
13LettuceVegetable3030Maximize<= 300
14GrapesFruit2025
15CatfishFish4535
16ChickenMeat7550
17ButterDairy3020
18TurkeyMeat5545
19CheeseDairy3520
20YogurtDairy5025
21MilkDairy7560

<tbody>
</tbody>
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Welcome to the board.

Here's one way:

Excel 2012
ABCDEFGHIJK
1ProductTypeProfitLbsBinaryTypeProductProfitLbs
2CarrotsVegetable100201Fruit3
3ApplesFruit80301Fruit14
4BananasFruit65250Vegetable2
5PorkMeat90501Vegetable13
6SalmonFish70351Dairy19
7TroutFish80251Dairy20
8HalibutFish45300Meat5
9OrangesFruit25350Meat11
10BeansVegetable25200Fish6
11BeefMeat80401Fish7
12TomatoVegetable40450635300
13LettuceVegetable30301Maximize<= 300Fruit2
14GrapesFruit20251Vegetable2
15CatfishFish45350Dairy2
16ChickenMeat75500Meat2
17ButterDairy30200Fish2
18TurkeyMeat55450
19CheeseDairy35201
20YogurtDairy50251
21MilkDairy75600

<tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
H12=SUMPRODUCT(C2:C21,$E2:$E21)
I12=SUMPRODUCT(D2:D21,$E2:$E21)
K13=COUNTIFS($B$2:$B$21,J13,$E$2:$E$21,1)

<tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
J2{=SMALL(IF($B$2:$B$21=F2,IF($E$2:$E$21=1,ROW($B$2:$B$21))),COUNTIF($F$2:$F2,F2))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



Put the heading "Binary" in E1. We'll use E2:E21 as a 0 or 1 to indicate whether we use this row or not. Then put the formulas in H12 and I12. Then put the categories in J13:J17. Put the formula in K13 and drag down to K17.

Now click Solver.

Maximize: H12
By Changing: E2:E21
Subject to Constraints:
$E$2:$E$21 = binary
$I$12 <= 300
$K$13:$K$17 = 2
Solving Method: Evolutionary.

Click Solve and wait a few moments. You should get the results above. This does not use any formulas in G2:I11. You can look at column E to see which ones are used. If you want to fill out the G2:I11 table, you can use the formula in J2 to get the appropriate row number, then put in INDEX formulas in G2:I11.

Good luck!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

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