So, I haven't been working on this for a while, but I've made some changes:
Sub LoopSolver()
Dim i As Integer
For i = 1 To X
SolverReset
SolverLoad loadArea:=Range("AE14:AH18")
SolverSolve Userfinish:=True
SolverFinish
Worksheets("Yahoo").Range("AJ1:AJ150").Copy Worksheets("Sheet2").Cells(1, X)
Range("AH1") = Range("AH1") - 0.01
Next
End Sub
The rundown is, I have my solver constraints saved in blocks AE14:AH18 on Sheet1. Each time solver runs, it SHOULD change the values of AJ1:AJ150, and it does so perfectly fine if I run it manually.
I then want to copy each iteration of solution to an individual column on Sheet2, as you can see. The [Range("AH1") = Range("AH1") - 0.01] part of the code modifies a constraint to prompt a new solution each iteration.
The problem is, when I run it inside this loop, I don't think solver is actually changing the values of the AJ1:AJ150 until the last iteration.
After I run the script, I get columns of invalid cell reference errors before the last column, which did successfully paste the solution. Basically, solver only works correctly on the last iteration of the loop.
Are there any pointers as to how I can store multiple solutions of solver in the manner that I described / identify what may be the issue?
Bookmarks