![]() |
Using the Solver in a VBA function (not a macro)
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 -- fm78 ------------------------------------------------------------------------ fm78's Profile: http://www.excelforum.com/member.php...o&userid=30370 View this thread: http://www.excelforum.com/showthread...hreadid=500249 |
All times are GMT +1. The time now is 05:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com