Hello,
I am trying to solve a cost optimization problem related to electricity generation and load. I am having trouble in editing the solver code for multiple rows (from 5 to 8764). I have tried this but this does not work and is showing error:
Sub Macro1()
Dim i As Integer
ActiveWorkbook.ActiveSheet.Activate
For i = 5 To 8764
SolverOk SetCell:="$L$" &i, MaxMinVal:=2, ValueOf:=0, ByChange:="$G$" & i &"$J$"&i, _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$G$" & i, Relation:=1, FormulaText:="$V$25"
SolverAdd CellRef:="$G$" & i, Relation:=3, FormulaText:="$U$25"
SolverAdd CellRef:="$H$" & i, Relation:=1, FormulaText:="$V$26"
SolverAdd CellRef:="$H$" & i, Relation:=3, FormulaText:="$U$26"
SolverAdd CellRef:="$I$" & i, Relation:=1, FormulaText:="$V$27"
SolverAdd CellRef:="$I$" & i, Relation:=3, FormulaText:="$U$27"
SolverAdd CellRef:="$J$" & i, Relation:=1, FormulaText:="$V$28"
SolverAdd CellRef:="$J$" & i, Relation:=3, FormulaText:="$U$28"
SolverAdd CellRef:="$K$" & i, Relation:=2, FormulaText:="$D$" & i
SolverSolve = True
End Sub
Bookmarks