Using Solver with a VBA Function

kato01

Board Regular
Joined
Sep 9, 2005
Messages
81
I am trying to use a UDF with the solver. The case shown below isa a slight modification of the video (
).

The only difference is that the expression for the goal B8 includes an additional factor, the value of the BIBI function.

It looks like the solver is ignoring the +BIBI(b1) component.

Any ideas?

Thank you.





see image attached

WHERE B8==3*B2+2*B3-B4+BIBI(B1) and

Solver.xlsm
ABCDEFGHIJKLM
1VariablesSolving Linear Programming Problem using Excel's Solver
2X19
3X25
4X30
5
6Objective
73*B2+2*B3-B4BIBI(B2)3*B2+2*B3-B4+BIBI(B1)
8Maximize37#NAME?#NAME?
9
10Constrants
11Inequality
12124<=9
13233>=2
14317>=5
1549>=0
1655>=0
1760>=0
VIDEO_CASE_WITH_FUNCTION
Cell Formulas
RangeFormula
F8F8=3*B2+2*B3-B4
H8H8=BIBI(B2)
J8J8=F8+H8
B12B12=B2+3*B3+B4
B13B13=2*B2+3*B3-B4
B14B14=3*B2-2*B3+B4
B15:B17B15=B2
Named Ranges
NameRefers ToCells
solver_adj=VIDEO_CASE_WITH_FUNCTION!$B$2:$B$4H8, F8, B12:B15


Function BIBI(X)

BIBI = X * X

End Function
 

Attachments

  • Screenshot 2023-05-07 123101.jpg
    Screenshot 2023-05-07 123101.jpg
    37.4 KB · Views: 3

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,215,061
Messages
6,122,922
Members
449,094
Latest member
teemeren

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