title: Visual Basic MacroSolve Loop error - Data only populates for last row and I want only roundup whole variables returned
body: <p>Below is my code and I have having two major issues:</p>
  
  <ol>
  <li><p>I want the change variables to be only whole values (rounded up) (ex: a patient only needs x amount of drug but package sizes are set amounts and remaining drug is wasted, I can't use 1 and half vials of drug, I must use 2 vials).</p></li>
  <li><p>My code only populates for the bottom row (36) and not at row count 25 where my data begins</p></li>
  </ol>
  
  <p></li></p>
  
  <pre><code>Sub MacroSolve()
  Worksheets("Sheet1").Activate
  Rowcount = 25
  Do While Not IsEmpty(Worksheets("Sheet1").Range("D" &amp; Rowcount))
   SolverReset
   SolverOptions precision:=0.001
   SolverOk SetCell:="$H$" &amp; Rowcount, MaxMinVal:=2, ValueOf:=0, ByChange:="$E$" &amp; Rowcount &amp; ":$F$" &amp; Rowcount
  
  
  SolverAdd CellRef:="$E$" &amp; Rowcount, Relation:=3, FormulaText:="0"
  SolverAdd CellRef:="$F$" &amp; Rowcount, Relation:=3, FormulaText:="0"
  
  SolverAdd CellRef:="$G$" &amp; Rowcount, Relation:=3, FormulaText:=Range("$D$" &amp; Rowcount)
  
  SolverAdd CellRef:="$H$" &amp; Rowcount, Relation:=3, FormulaText:=Range("$F$21")
  
  SolverSolve UserFinish:=True
  SolverFinish keepFinal:=1
  Rowcount = Rowcount + 1
  Loop
  End Sub
  </code></pre>