F
fm78
Hi,
I got some kind of a standard problem but could not find any solution
for it up to now. Here the setting: I want to program a VBA function
(not a macro!). The function should optimize some expression depending
on its input parameters (a, b, and c) by using the Solver (e.g. I want
to call Solver for getting a solution rather than programing some
iterations myself). E.g. something like the following will be
required:
Function SolverInVBA(a, b, c)
x = 0 'some dummy as starting point for the optimization
y = a * x^2 + b * x + c 'just some stupid example
SolverReset
-----------------Here comes the problem-----------------
SolverOk SetCell:="y"(???), MaxMinVal:=2, ByChange:="x"(???)
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
SolverInVBA = "Solution of Solver"(???)
---------------------------------------------------------
End Function
The points where I have problems are marked with "(???)". In addition,
how do I tell the function to update once one of its input parameters
has changed? Has anybody an idea how to implement this?
Best,
Felix
I got some kind of a standard problem but could not find any solution
for it up to now. Here the setting: I want to program a VBA function
(not a macro!). The function should optimize some expression depending
on its input parameters (a, b, and c) by using the Solver (e.g. I want
to call Solver for getting a solution rather than programing some
iterations myself). E.g. something like the following will be
required:
Function SolverInVBA(a, b, c)
x = 0 'some dummy as starting point for the optimization
y = a * x^2 + b * x + c 'just some stupid example
SolverReset
-----------------Here comes the problem-----------------
SolverOk SetCell:="y"(???), MaxMinVal:=2, ByChange:="x"(???)
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
SolverInVBA = "Solution of Solver"(???)
---------------------------------------------------------
End Function
The points where I have problems are marked with "(???)". In addition,
how do I tell the function to update once one of its input parameters
has changed? Has anybody an idea how to implement this?
Best,
Felix