View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default Excel Solver as User Defined Funcntion

question is whether we can define a UDF that invokes a solver?

Hi. Internally, Solver is a Subrotine, so one can not call it like a
regular function, if that is what you mean.
If you take the above question literally, then "yes", with some setup
involved.
Solver's subroutines interact with the spreadsheet. You need to set up
everything first on a spreadsheet.
For Example, you must have a Target Cell, and have Changing cells.
One would never really program it as a function. The usualy way to to run a
Sub, find a soluion, and if desired, copy the soluion to a desired location.
Depending on what you are doing, does anything here give you any ideas??
Again, you must set up solver first.

Sub Demo()
[A1] = SolverSolution
End Sub

Function SolverSolution()
Dim Chk As Long
' Set up Solver...then
Chk = SolverSolve(True)
' If Chk is valid...then
SolverSolution = [Target]
End Function

--
HTH :)
Dana DeLouis
Windows XP & Office 2007


"Murthy" wrote in message
...
Thanks for getting back to me. What I want is close to this. But still my
question is whether we can define a UDF that invokes a solver?

Regards.

"Gary''s Student" wrote:

see:


http://groups.google.com/group/micro...0b795e4792216f



--
Gary''s Student
gsnu200708


"Murthy" wrote:

Hi all:

Can someone give me an idea of how to define excel solver as an user
defined
function? Say A3 = CallSolver(Inputs, Retrun Output)... something in
those
lines.

Regards.