title: Excel Solver Error while using VBA
body: <p>I have the following code which is basically a macro recorded. after recording the macro, I cleaned away some lines of code that were found repetitive. When I try to run this code again I get a Sub or Function not defined error. I checked out other Solver VBA questions on Stackoverflow and I dont seemt to be doing anything wrong. Can anyone please help? Thanks in advance.</p>
  
  <pre><code>Sub Macro2()
  
  SolverOk SetCell:="$BF$7", MaxMinVal:=2, ValueOf:=0, ByChange:="$BA$7:$BC$7", Engine:=2, EngineDesc:="Simplex LP"
  
  SolverAdd CellRef:="$BA$7", Relation:=4, FormulaText:="integer"
  SolverAdd CellRef:="$BA$7", Relation:=3, FormulaText:="0"
  
  SolverAdd CellRef:="$BB$7", Relation:=4, FormulaText:="integer"
  SolverAdd CellRef:="$BB$7", Relation:=3, FormulaText:="0"
  
  SolverAdd CellRef:="$BC$7", Relation:=3, FormulaText:="0"
  SolverAdd CellRef:="$BC$7", Relation:=4, FormulaText:="integer"
  
  SolverAdd CellRef:="$BE$7", Relation:=3, FormulaText:="0"
  
  SolverOk SetCell:="$BF$7", MaxMinVal:=2, ValueOf:=0, ByChange:="$BA$7:$BC$7", Engine:=2, EngineDesc:="Simplex LP"
  
  SolverSolve
  End Sub
  </code></pre>