Visual Basic Macro For Solver

  • Thread starter Thread starter Velero
  • Start date Start date
V

Velero

I would like to know how to creat a macro for Resetill all
the Solver options, before assinging parameters and run
it. The follwing example, taken from the microsoft
website, illustrates what´s going on. The macro runs okay,
but each time is saving the constraints on the window. I
presume it must be added an argument to reset all before.
Any help will be appreciated.

Velero


http://support.microsoft.com/default.aspx?
scid=/support/excel/content/solver/solver.asp

Sub Maximum_Profit()


Solverok setcell:=Range("G14"), maxminval:=1, _
bychange:=Range("G9:I9")
SolverAdd CellRef:=Range("E3:E7"), Relation:=1, _
FormulaText:="$B$3:$B$7"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1

End Sub
 
I would like to know how to creat a macro for Resetill all
the Solver options, before assinging parameters and run
it. The follwing example, taken from the microsoft
website, illustrates whatïs going on. The macro runs okay,
but each time is saving the constraints on the window. I
presume it must be added an argument to reset all before.

Are you saying that you want the macro to note what the existing options
are for Solver, save them somewhere, and restore them to the solver dialog
box after it completes?

I don't think that's possible.
 
No, I am not saying that. Let me explain it again

I want to write a macro for running solver. The problem is
that each time you run it the Solver window in Excel is
saving the constraints (adding again the arguments in the
constraint window). I need to add an argument in order to
Reset all before seting the target, changing, and
constraint arguments.

Does this help as explanation?

Thanks for your answer

Velero
 
Is this what you are looking for?

SolverReset

SolverOk _
SetCell:=Range("G14"), _
MaxMinVal:=1, _
ByChange:=Range("G9:I9")

'...etc


Not sure, but for Jonathan's idea, I believe "SolverSave" and "SolverLoad"
are one method of saving/loading Solver options.
HTH.

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


No, I am not saying that. Let me explain it again

I want to write a macro for running solver. The problem is
that each time you run it the Solver window in Excel is
saving the constraints (adding again the arguments in the
constraint window). I need to add an argument in order to
Reset all before seting the target, changing, and
constraint arguments.

Does this help as explanation?

Thanks for your answer

Velero
 
Back
Top