title: Solver VBA, how to paste "SolverSolve return value" for every row
body: <p>I have created the following macro, which loops through a set of rows optimising product price for every row.</p>
  <pre><code>Sub OptimizePrice()
  Dim i As Integer
  ActiveWorkbook.ActiveSheet.Activate
  For i = 5 To 20
  SolverReset
  SolverOk SetCell:=&quot;$K$&quot; &amp; i, MaxMinVal:=1, ByChange:=&quot;$B$&quot; &amp; i, Engine:=1
  SolverAdd CellRef:=&quot;$B$&quot; &amp; i, Relation:=1, FormulaText:=&quot;$E$&quot; &amp; i
  SolverAdd CellRef:=&quot;$F$&quot; &amp; i, Relation:=1, FormulaText:=&quot;$G$&quot; &amp; i
  SolverSolve True
  Range(&quot;$L$&quot; &amp; i)= SolverSolve Return Value
  Next i
  End Sub
  </code></pre>
  <p>Sometimes Solver finds an optimal solution, sometimes it doesn't. I want my macro to PASTE for every row in column &quot;L&quot;, the result of the operation, which ranges from 0 to 20 according to the description provided in the following webpage: <a href="https://www.solver.com/excel-solver-solversolve-function" rel="nofollow noreferrer">https://www.solver.com/excel-solver-solversolve-function</a>.</p>
  <p>I've tried to achieve this with this line of code 'Range(&quot;$L$&quot; &amp; i)= SolverSolve Return Value' but it seems it's not the right way to get the returnvalue type.</p>
  <p>Your help is appreciated!.</p>