title: Set cell in solver VBA by changing more than one cell?
body: <p>I am trying to use solver in Excel VBA to set a cell by changing 3 other cells. However, the three cells don't change by the values that I choose (I put a solver add in for every colomn to be bigger and lesser than specific value), it seemes like the solver can't read what I have given to it.</p>
  
  <p>I need to know how to make it read the three constant and make the changes based on them.</p>
  
  <pre><code>Sub solver()
  
  For i = 5 To 48
      SolverReset
      objstring = "$I$" &amp; i
  
      SolverOk SetCell:=Range(objstring), MaxMinVal:=2, ValueOf:=0, ByChange:=Range("C5:E7")
      SolverAdd CellRef:="$C$5:$C$48", Relation:=1, FormulaText:=934000
      SolverAdd CellRef:="$C$5:$C$48", Relation:=3, FormulaText:=953000
      SolverAdd CellRef:=Range("$D$" &amp; i), Relation:=1, FormulaText:="$B$13"
      SolverAdd CellRef:=Range("$D$" &amp; i), Relation:=3, FormulaText:="$B$14"
      SolverAdd CellRef:=Range("$E$" &amp; i), Relation:=1, FormulaText:="$B$15"
      SolverAdd CellRef:=Range("$E$" &amp; i), Relation:=3, FormulaText:="$B$16"
  
      SolverSolve userfinish:=True
  
  Next i
  
  End Sub
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/dS7x3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dS7x3.jpg" alt="[1]: https://i.stack.imgur.com/dS7x3.jpg"></a></p>