![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Location: London UK
Posts: 6
|
Hi,
I'm trying to assign a solver to a macro. I've recorded myself doing it, but, it gets errors all the way through when I try and run it. Any ideas about why it's struggling are much appreciated. >>> Sub solver3() SolverReset SolverOk SetCell:="$D$43", MaxMinVal:=1, ValueOf:="0", ByChange:="$F$13:$F$14" SolverAdd CellRef:="$F$13", Relation:=3, FormulaText:="0" SolverAdd CellRef:="$F$14", Relation:=3, FormulaText:="0" SolverAdd CellRef:="$F$13", Relation:=1, FormulaText:="500" SolverAdd CellRef:="$F$14", Relation:=1, FormulaText:="500" SolverAdd CellRef:="$F$13", Relation:=4, FormulaText:="integer" SolverAdd CellRef:="$F$14", Relation:=4, FormulaText:="integer" SolverAdd CellRef:="$D$45", Relation:=1, FormulaText:="$G$4" SolverOk SetCell:="$D$43", MaxMinVal:=1, ValueOf:="0", ByChange:="$F$13:$F$14" SolverSolve End Sub |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
I don't think we can really tell if there is something wrong with your model, or that the code doesn't execute, based on the information given. To use the Solver with VBA, you must set a reference to it in the procedure before it can work. In the VBE, Tools->References->Solver.xls checked. HTH, Jay EDIT: In addition, be careful with the integer and binary constraints. I have read that Solver can be a bit flaky with discontinuous contraints. [ This Message was edited by: Jay Petrulis on 2002-05-23 10:02 ] |
|
|
|
|
|
#3 |
|
New Member
Join Date: May 2002
Location: London UK
Posts: 6
|
thanks - i'll check up on that.
I'm sure the model does work (i appreciate the discontinuous issue, but, all my sources are continuous)as I have done it manually. V much appreciated anyway. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|