title: VBA Solver disabling the dialog box that pops after each iteration
body: <p>I am using the built-in solver in Excel 2007 within a VBA loop to solve a number of different problems. Occasionally, the solver hits the maximum time, which causes a pop-up dialog box to appear asking whether the user wants to Continue, Stop, or End. In all cases I want it to end, and proceed to the next line of the loop. This will prevent a user from having to sit there and respond each time.</p>
  
  <p>I ran a macro with the solver pass thru method (<a href="https://stackoverflow.com/questions/3984584/catch-max-time-iteration-dialog-box-when-using-excel-solver-in-vba">Catch max time/iteration dialog box when using Excel Solver in VBA</a>) but then it gives me another dialog box saying "The formula you typed contains an error"</p>
  
  <p>I also tried <a href="http://msdn.microsoft.com/en-us/library/office/ff197237(v=office.15).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/office/ff197237(v=office.15).aspx</a> .
  Which is a less complicated version of 'The solver pass thru method' but after each iteration it gives me the same message as "The formula you typed contains an error"
  This is my code</p>
  
  <pre><code>Sub Optimize()
  '
  ' OptimizeShortfall Macro
  '
  
  '
  Set MyFirstObj = Range("I124")
  Set MyFirstRange = Range("H600:H698")
  Dim i As Integer
  For i = 0 To 1
      MyObj = MyFirstObj.Offset(0, i).Address
      MyTestRange = MyFirstRange.Offset(0, i).Address
      SolverReset
      SolverOk SetCell:=MyObj, MaxMinVal:=1, ValueOf:="0", ByChange:= _
          MyTestRange
      SolverAdd CellRef:=MyTestRange, Relation:=1, FormulaText:="100%"
      SolverOptions MaxTime:=20, Iterations:=100, Precision:=0.000001, AssumeLinear _
          :=False, StepThru:=False, Estimates:=1, Derivatives:=1, SearchOption:=1, _
          IntTolerance:=5, Scaling:=False, Convergence:=0.0001, AssumeNonNeg:=True
       SolverSolve UserFinish:=True, ShowRef:="SolverIteration"
      Next i
  End Sub
  
  Function SolverIteration(Reason As Integer)
      MsgBox Reason
      SolverIteration = 1
  End Function
  </code></pre>