Bernie wrote:
For Each X In Range("D8:D17")
For Each Y In Range("E7:K7")
Range("D1").Value = X.Value
SolverOk SetCell:="$D$3", MaxMinVal:=3, ValueOf:=Y.Value, ByChange:="$D$2"
SolverSolve True
Cells(X.Row, Y.Column).Value = Range("D2").Value
Next Y
Next X
Bernie, would it be prudent to add Range("D3").ClearContents at the beginning of the inner loop?
[ERRATA] I meant the by-changing cell, not the objective cell. So Range("D2").ClearContents. All references to "target cell" below should be "by-changing cell".
When I use Solver manually, it seems that (sometimes?) it uses any value in the target cell as an initial value for its algorithm. Or more accurately: any value in the target cell seems to impact the behavior of Solver.
That might depend on the Solver method. But for some set-ups, I do get different values depending on whether the target cell is empty or it has a value (e.g. from a previous run of Solver).
[EDIT] But that might be the case only when the Solver parameters are not changed between runs. I have not done much to investigate this observation. I usually simply clear the target cell "autonomically" before using Solver.