Hello guys.
I was having trouble running the Solver in multiple rows. However, I saw in this forum several threats that helped me evolve a lot using VBA (I'm starting my studies now in this language and solved the problem with Solver in a Loop).
I know it must be something simple that I'm missing, however, I cannot do that for two columns at a time (in this case, the P and the R columns).
Here are the spreadsheet and the code.
I would also like to add the R column.
Best Regards,
Gláuber.
Set Objective: $AI$12
To: Min
By Changing: $P$12;$R$12
Option Explicit
Sub LoopSolv()
Dim i As Integer
For i = 12 To Range("P" & Rows.count).End(xlUp).Row
If Cells(i, "P") <> "" Then
SolverReset
SolverOk SetCell:=Cells(i, "AI").Address, MaxMinVal:=2, ValueOf:=0, ByChange:=Cells(i, "P").Address, Engine:=1 _
, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:=Cells(i, "AI").Address, Relation:=2, FormulaText:=Cells(i, "AI").Address
SolverSolve Userfinish:=True
End If
Next
End Sub
Bookmarks