0

I am trying to loop a solver command down a specific row of target cells with the ByChange range and ValueOf range also changing with each loop.

Essentially so that I don't have to do this manually down a table.

So far I have:

Sub loop_solver()

Dim i As Long

For i = 1 To 10

    SolverReset
    SolverOptions precision:=0.001

    SolverOk SetCell:=Range("S & i"), ByChange:=Range("O & i:Q & i"), _
        MaxMinVal:=3, ValueOf:=Range("T & i")

    SolverSolve UserFinish:=True

    SolverFinish KeepFinal:=1

Next

End Sub

I also need to work in a constraint that also changes cell with every loop.

1 Answer 1

1

Just so anyone who is interested. I got my code to work by adding a .offset as I realised you can't count the loop within a range.

Sub loop_solver()

Dim i As Long

For i = 0 To 10

   SolverReset
   SolverOptions precision:=0.001

   SolverOk SetCell:=Range($S$3).Offset(i,0), ByChange:=Range("$O$3:$Q$3").Offset(i,0), _
        MaxMinVal:=3, ValueOf:=Range("$T$3").Offset(i,0)

   SolverSolve UserFinish:=True

   SolverFinish KeepFinal:=1

Next

End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.