View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dana DeLouis
 
Posts: n/a
Default Macros involving SOLVER... function

In the vba editor, go to Tools | Reference, and set a reference to "Solver."
In your code, I believe your left out a reference to the Target Cell (ie
SetCell).
If you keep calling Solver, you will eventually have too many redundant
constraints.
I find it best to start from scratch with SolverReset.

SolverReset
SolverOk SetCell:="A1", MaxMinVal:=1, ByChange:="D9:D10"
SolverAdd CellRef:="A9:A10", Relation:=2, FormulaText:="B9:B10"
SolverSolve True

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"Pixies" wrote in
message ...

My intial problem was to solve a simultaneous equation using excel.

You can do this using Tools Solver...

Now I wanted to create a macro so everytime I change my constraints< I
can run the macro which would in turn run the commands in Solver...

I did this BUT when I actually ran the macro again I got this error:

Compile Error:
Sub or Function not defined.

Macro:
Sub last()
'
' last Macro
' Macro recorded 19.04.2006 by Lewis Holland
'

'
SolverOk MaxMinVal:=1, ValueOf:="0", ByChange:="$D$9:$D$10"
SolverAdd CellRef:="$A$9:$A$10", Relation:=2,
FormulaText:="$B$9:$B$10"
SolverOk MaxMinVal:=1, ValueOf:="0", ByChange:="$D$9:$D$10"
SolverSolve
End Sub

Can anyone help solve this?
Can you record a macro which actually uses this Solver.. function?


--
Pixies
------------------------------------------------------------------------
Pixies's Profile:
http://www.excelforum.com/member.php...o&userid=33642
View this thread: http://www.excelforum.com/showthread...hreadid=534142